Look at the discussion under the topic "Activity Question" couple days ago
webmonkey wrote: 27. August 2008 20:25 --------------------------- there is no need to use singleTask, singleTop or any other special flags. It has something to do with the way Eclipse re- installs your application. If you run without using Eclipse everything should work fine. I do the following to get the correct behaviour: 1. I run my app in Eclipse using Run > Run History > myApp. The app opens up with the home activity 2. I hit the Back button. The Android home screen with the app menu is displayed 3. I start my app from the Android app menu. The app opens up with the home activity 4. From now on, it will work as expected so when I press Home in a 'secondary' activity and then restart my App again from the Android app menu it will go back to the 'secondary' activity. --- On Aug 29, 12:09 pm, Guillaume Perrot <[EMAIL PROTECTED]> wrote: > about onRestoreSavedInstanceState: I misunderstood the doc, I now > understand why it was not called in my case. Sorry. > > about onNewIntent: > In fact there is a very strange problem: if I launch my application > from Eclipse, the mechanism will not work, but if I shutdown my > emulator then relauch emulator then my application it works... > Here is a simplified test app which illustrates the mechanism of > relaunching my app with a "command" from the notification bar. This > application always works, strangely, the mechanism is exactly the same > in my real application... > > public class Test extends Activity > { > @Override > public void onCreate(Bundle savedInstanceState) > { > Log.d("test", "onCreate(savedInstanceState=" + savedInstanceState > + ")"); > super.onCreate(savedInstanceState); > setContentView(R.layout.main); > > displayIntentExtras(); > > Intent intent = new Intent(this, Test.class); > //intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); > intent.putExtra("dummy", "dummy"); > Notification notification = new Notification(R.drawable.icon, > "relaunch with dummy extra", System.currentTimeMillis()); > notification.setLatestEventInfo(this, "relaunch app", > "relaunch with dummy extra", PendingIntent > .getActivity(this, 0, intent, 0)); > > NotificationManager notificationManager = (NotificationManager) > getSystemService(Context.NOTIFICATION_SERVICE); > notificationManager.notify(1, notification); > } > > private void displayIntentExtras() > { > Log.d("test", "dummy=" + getIntent().getStringExtra("dummy")); > } > > @Override > protected void onStart() > { > Log.d("test", "onStart()"); > super.onStart(); > } > > @Override > protected void onRestart() > { > Log.d("test", "onRestart()"); > super.onRestart(); > } > > @Override > protected void onNewIntent(Intent intent) > { > Log.d("test", "onNewIntent(intent=" + intent + ")"); > setIntent(intent); > displayIntentExtras(); > super.onNewIntent(intent); > } > > } > > <?xml version="1.0" encoding="utf-8"?> > <manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="test.test"> > <application android:icon="@drawable/icon" android:label="@string/ > app_name"> > <activity android:name=".Test" android:label="@string/ > app_name" android:launchMode="singleTop"> > <intent-filter> > <action android:name="android.intent.action.MAIN" /> > <category > android:name="android.intent.category.LAUNCHER" /> > </intent-filter> > </activity> > </application> > </manifest> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---