Android “single top” launch mode and onNewIntent method

Put your problem here if it does not fit any of the other categories.

Android “single top” launch mode and onNewIntent method

Postby Jasp182 » Wed Nov 11, 2009 1:12 am

I read in the Android documentation that by setting my Activity's launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would reuse a single Activity instance and give me the Intent in the onNewIntent callback. I did both of these things, and onNewIntent never fires and onCreate fires every time. The docs also say that this.getIntent() returns the intent that was first passed to the Activity when it was first created. In onCreate I'm calling getIntent and I'm getting a new one every time (I'm creating the intent object in another activity and adding an extra to it...this extra should be the same every time if it was returning me the same intent object). All this leads me to believe that my activity is not acting like a "single top", and I don't understand why.

To add some background in case I'm simply missing a required step, here's my Activity declaration in the manifest and the code I'm using to launch the activity. The Activity itself doesn't do anything worth mentioning in regards to this:

in AndroidManifest.xml:

in my calling Activity:

Intent i = new Intent();
i.putExtra(EXTRA_KEY_ARTIST, id);
i.setClass(this, ArtistActivity.class);
Posts: 6
Joined: Tue Nov 03, 2009 1:30 pm
Location: Boston


Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests