Getting Bundle On Main Activity When Passing Bundles By Intent In Android
So the problem I am having is that my app keeps crashing on launch, I have two activities. Activity A and Activity B. My app launches on Activity A but I have created a bundle in A
Solution 1:
I would suggest the following:
A. Use Bundle from Intent:
IntentpIntent=newIntent(this, JustaClass.class);
Bundleextras= pIntent.getExtras();
extras.putString(key, value);
B. Create a new Bundle:
IntentpIntent=newIntent(this, JustaClass.class);
BundlepBundle=newBundle();
pBundle.putString(key, value);
mIntent.putExtras(pBundle);
C. Use putExtra() method of the Intent:
Intent pIntent = newIntent(this, JustaClass.class);
pIntent.putExtra(key, value);
Finally in the launched Activity, you can read them hrough:
String value = getIntent().getExtras().getString(key)
I just used Strings as an example for passing, I refer to Bundle and Intent.
Post a Comment for "Getting Bundle On Main Activity When Passing Bundles By Intent In Android"