我正在運行下面的代碼。有兩個片段。首先是我如何設置包,第二是我如何檢索它。由於某種原因,每次我檢查包時,它都返回爲空。Android意圖包總是空?
任何意見,爲什麼這是或我做錯了什麼將不勝感激。
Intent intent = new Intent(this, com.hom.app.Hom.class);
Bundle b = new Bundle();
b.putString("WELL", "yes");
intent.putExtras(b);
startActivity(intent);
檢索軟件包:
String well ="";
Bundle bun = getIntent().getExtras();
String standard = "yes";
if(bun != null){
Log.v("Bundle", "Contains data");
well = bun.getString("WELL");
if(well == null) well = "";
if(well == standard) method();
}
你有沒有得到這個工作? – JoeLallouz