android - Resume old activity by passing new data in bundle -
i have couple of activities , b, c. activity starts b , b starts c , on. in app have set navigation drawer allows users go activity a. when user goes activity have passed flags don't restart activity resumes it.
intent = new intent(activity, a.class); intent.setflags(intent.flag_activity_clear_top | intent.flag_activity_single_top);
now m trying pass info using bundles.
bundle.putint("selectedtab", featured_coupons); intent.putextras(bundle);
but in activity bundle null.
if(bundle != null) { if(bundle.containskey("selectedtab")) { int tab = bundle.getint("selectedtab"); } }
you're going things in wrong way.
if want set integer
intent
extras don't this...
bundle.putint("selectedtab", featured_coupons); intent.putextras(bundle);
from docs putextras(bundle extras)
...
add set of extended info intent. the keys must include bundle prefix, illustration app com.android.contacts utilize names "com.android.contacts.showall".
instead use...
intent.putextra("selectedtab", featured_coupons);
this isn't real cause of problem however. sumit uppal mentions, should implement onnewintent(intent intent) in activity
a. can utilize set 'current' intent
new intent
...
@override protected void onnewintent(intent intent) { if (intent != null) setintent(intent); }
then in onresume()
can use...
intent intent = getintent();
...and bundle
intent
.
android android-intent android-activity android-bundle
No comments:
Post a Comment