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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en