Actually, to me it sounds it's behaving correctly... If Activity B is standard then it might be re-used, so it's not obliged to create a new Instance... Thats what happens in ur case, first time it get's created, then you go to activity A, then when you ask for Activity B the "old" activity B is returned... If you don't want that as a behaviour you might declare B as singleInstance or even better singleTask...
On 21 jun, 13:30, Vibhor Mahajan <mahajan.vib...@gmail.com> wrote: > Hello, > > What is launch mode of an activity, which is launched from an activity > with launch mode as "singleinstance". I tried the following code. > > My application has two activities i.e. A & B. Activity A has > "singleinstance" launchmode set and activity B has "standard" launch > mode set. Android manifest file is as follows: > > <application android:icon="@drawable/icon" android:label="@string/ > app_name" > > <activity android:name=".activity_lifecycle" > android:label="@string/app_name" > android:launchMode="singleInstance"> > <intent-filter> <action > android:name="android.intent.action.MAIN" /> > <category > android:name="android.intent.category.LAUNCHER" /> > </intent-filter> > </activity> > <activity android:name=".another" > android:launchMode="standard" ></activity> > </application> > > Activity A has a button, clicking button starts Activity B using below > code: > public void onClick(View v) { > // TODO Auto-generated method stub > Intent intent = new > Intent(activity_lifecycle.this,another.class); > startActivityForResult(intent, 0); > > } > > Activity B has a button, clicking button starts Activity A using below > code: > public void onClick(View v) { > // TODO Auto-generated method stub > Intent intent = new > Intent(another.this,activity_lifecycle.class); > startActivityForResult(intent, 0); > > } > > Click button in Activity A starts B. (oncreate of B is called) > Click button in Activity B re-starts A. (because A has SINGLEINSTANCE > launchmode) > Click button in Activity A re-starts B. (oncreate of B is NOT CALLED) > > After 3rd step, since activity B is standard, a new instance should be > created and not previous instance to be used. > > Kindly suggest why when second time activity B is started, a new > instance of activity B is not created, when it is declared with > launchmode "standard". > > Regards, > Vibhor -- 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 android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en