から活動にエキストラを送信namely- D_EngNameScreen、D_LocNameScreen、D_GenCharScreen、D_PathSNameScreenとDisease_InformationScreen。ここでは最初の4つの活動が最後の活動へ意図とバンドル(Disease_InformationScreen)を介してエクストラを送っています。 コードは、私がこの場合D_EngNameScreen活動が正常Disease_InformationScreen活動にエキストラを送信しているが、残りは行っていないは私が5つの活性を有する複数の活動
if (getIntent().getExtras() != null) {
if (getIntent().getStringExtra("NAVIGATIONTYPE").contentEquals("EnglishName")) {
Bundle getcrop = getIntent().getExtras();
cropname_en = getcrop.getString("CROPNAME_EN");
Log.d("CNAME: ", cropname_en);
d_EngName = getcrop.getString("DENGNAME");
Log.d("DENGNAME: ", d_EngName);
danme12.setText(d_EngName);
} else if (getIntent().getStringExtra("NAVIGATIONTYPE").contentEquals("LocalName")) {
Bundle getcrop = getIntent().getExtras();
cropname_ln = getcrop.getString("CROPNAME_LN");
Log.d("CNAME: ", cropname_ln);
d_LocName = getcrop.getString("DLOCALNAME");
} else if (getIntent().getStringExtra("NAVIGATIONTYPE").contentEquals("PathogenName")) {
Bundle getcrop = getIntent().getExtras();
cropname_pn = getcrop.getString("CROPNAME_PN");
d_PathName = getcrop.getString("DPATHOSCINAME");
} else if (getIntent().getStringExtra("NAVIGATIONTYPE").contentEquals("GeneralChar")) {
Bundle getcrop = getIntent().getExtras();
cropname_gc = getcrop.getString("CROPNAME_GC");
d_SprdMode = getcrop.getString("SPREADMODE");
d_PathCE = getcrop.getString("PATHOGENCONENV");
}
}
アクティビティ - Disease_InformationScreenでエキストラを受け付けております
// from the D_EngNameScreen activity
Intent intentDENG = new Intent(D_EngNameScreen.this, Disease_InformationScreen.class);
d_eng_Name_Bundle.putString("CROPNAME_EN",crop_en);
d_eng_Name_Bundle.putString("DENGNAME",d_EngName);
intentDENG.putExtra("NAVIGATIONTYPE","EnglishName");
intentDENG.putExtras(d_eng_Name_Bundle);
startActivity(intentDENG);
//from the D_LocNameScreen activity
Intent intentDLN = new Intent(D_LocNameScreen.this, Disease_InformationScreen.class);
d_local_name_bundle.putString("CROPNAME_LN",crop_ln);
d_local_name_bundle.putString("DLOCALNAME",d_Locname);
intentDLN.putExtra("NAVIGATIONTYPE","LocalName");
intentDLN.putExtras(d_local_name_bundle);
startActivity(intentDLN);
//from the D_GenCharScreen activity
Intent intentDGENCHAR = new Intent(D_GenCharScreen.this, Disease_InformationScreen.class);
d_gen_char_bundle.putString("CROPNAME_GC",crop_gc);
d_gen_char_bundle.putString("SPREADMODE",d_spread_Items);
d_gen_char_bundle.putString("PATHOGENCONENV",d_patho_environ_Items);
intentDGENCHAR.putExtra("NAVIGATIONTYPE","GeneralChar");
intentDGENCHAR.putExtras(d_gen_char_bundle);
startActivity(intentDGENCHAR);
//from the D_PathSNameScreen activity
Intent intentDPSN = new Intent(D_PathSNameScreen.this,Disease_InformationScreen.class);
d_pathoName_bundle.putString("CROPNAME_PN",crop_pn);
d_pathoName_bundle.putString("DPATHOSCINAME",d_pathosci_name);
intentDPSN.putExtra("NAVIGATIONTYPE","PathogenName");
intentDPSN.putExtras(d_pathoName_bundle);
startActivity(intentDPSN);
をare-同じ。それはDisease_InformationScreenアクシビティにエクストラを送信している間に、残りの3つのアクティビティーでヌルポインター例外を表示しています -
d_local_name_bundle.putString("CROPNAME_LN",crop_ln);//for example
Logcatだから、この問題で私を助けてください
05-20 11:40:27.365 15619-15619/com.thesiswork.ashraf.ashrafresearchwork E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at com.thesiswork.ashraf.ashrafresearchwork.D_LocNameScreen.onClick(D_LocNameScreen.java:123)
at android.view.View.performClick(View.java:4212)
at android.view.View$PerformClick.run(View.java:17476)
at android.os.Handler.handleCallback(Handler.java:800)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5371)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
をIS-
のオブジェクトを作成していないと思います例外 –
また、それはnullポインタの例外はかなりわかりやすい –
あなたはrを返すカスタムアクティビティを実装する必要がありますあなたは 'startActivityForResult()'アクティビティを開始します。 –