I have three activities that I can call A, B and C. I want to pass information between the three like this: A-->B-->C-->A. In A I want to check if there is a bundle passed (the first time, start-up, there won't be one for example). The data is passed from A-B with a normal bundle. From B-->C I use this:
Intent i = new Intent(getApplicationContext(), FlashcardView.class);
i.putExtra("rattning", rattning);
i.putExtra("noqs", noqs);
i.putExtra("categoryid", categoryid);
CreateTestView.this.finish();
startActivityForResult(i, 0);
It is received and then sent onwards to A like this:
Intent data = new Intent(FlashcardView.this, MenuView.class);
data.putExtra("point", point);
data.putExtra("noqs", noqs);
setResult(RESULT_OK, data);
finish();
It is received at A like this:
@Override
protected void onActivityResult( int req, int resp, Intent data ) {
super.onActivityResult(req, resp, data);
// process your received "data" from GameActivity ...
Bundle b = getIntent().getExtras();
noqs = b.getInt("noqs");
point = b.getInt("point");
mTvCat.setText("hhhhhh"+point+noqs);
publishOnFacebook(point,noqs);
}
It seems though like the bundle is lost on the way from C-->A. When I passed it back from C-->B there was no problem. I think this happens cause B is the activity that starts C, and therefore C falls back to B, not A. I made a go-around by calling finish() on B, so C goes back to A instead. BUt in doing this I lose the bundle. Or at least I think so.
Has anyone seen this before? Is there a better way of doing this? How can I prevent losing the bundle on a passing between more than two activities? THanks!
Edit:
Edit: Here is the error code on receiving the broadcast:
03-07 12:57:59.394: ERROR/AndroidRuntime(803): java.lang.RuntimeException: Error receiving broadcast Intent { act=my_action (has extras) } in com.crystalcodeab.Flashcard.MenuView$1@47681ad0
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at android.app.ActivityThread$PackageInfo$ReceiverDispatcher$Args.run(ActivityThread.java:981)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at android.os.Handler.handleCallback(Handler.java:587)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at android.os.Handler.dispatchMessage(Handler.java:92)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at android.os.Looper.loop(Looper.java:143)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at android.app.ActivityThread.main(ActivityThread.java:5068)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at java.lang.reflect.Method.invokeNative(Native Method)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at java.lang.reflect.Method.invoke(Method.java:521)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at dalvik.system.NativeStart.main(Native Method)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): Caused by: java.lang.NullPointerException
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at com.crystalcodeab.Flashcard.MenuView$1.onReceive(MenuView.java:56)
03-07 12:57:59.394: ERROR/AndroidRuntime(803): at