Hello,

As per the documentation, standard and singletop differ in just one way,
standard activity instance is created every time but singletop instance may
or may not be created. I verified this, if in the above code, reverse
launchmode of activity A & B i.e. Now A has STANDARD and B as
SINGLEINSTANCE.

Repeat same steps again:
1. Click button in Activity A starts B. (oncreate of B is called)
2. Click button in Activity B creates a new instance A. (oncreate of A is
called, because A now has STANDARD launchmode)
3. Click button in Activity A re-starts B. (oncreate of B is NOT CALLED,
because B now has SINGLEINSTANCE launchmode)

This is exactly as per the documentation.

Kindly help in understanding why in original source code, multiple instances
of B is not created, though B is having STANDARD launch mode?

Thanks,
Vibhor

On Mon, Jun 21, 2010 at 8:15 PM, MobDev <developm...@mobilaria.com> wrote:

> Btw, got this from documentation, concentrate on the last sentence :
> "Every time there's new intent for a "standard" activity, a new
> instance of the class is created to respond to that intent. Each
> instance handles a single intent. Similarly, a new instance of a
> "singleTop" activity may also be created to handle a new intent.
> However, if the target task already has an existing instance of the
> activity at the top of its stack, that instance will receive the new
> intent (in an onNewIntent()  call); a new instance is not created."
> found here :
>
> http://developer.android.com/guide/topics/manifest/activity-element.html#lmode
>
> 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<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
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

Reply via email to