Thanks for posting, I'll make a new project with your code to test. Although my G1 is running 1.5, my emulator is using 2.0, so it should be testing both situations. Will try yours now,
Thanks On Feb 19, 11:21 am, jotobjects <[email protected]> wrote: > Yes in the last step I get back to ActivityB and you get back to > ActivityA so that's different behavior. The only environment > difference apparently is that your test is with 1.5 and my test is > with 2.0.1, but it doesn't seem like this core behavior would have > changed. Here is my app. I'll test your app also. > > <?xml version="1.0" encoding="utf-8"?> > <manifest xmlns:android="http://schemas.android.com/apk/res/android" > package="foo.singletask" > android:versionCode="1" > android:versionName="1.0"> > <uses-sdk android:minSdkVersion="3" /> > <application android:label="SimpleSingleTask"> > <activity android:name=".ActivityA" > launchMode="singleTask"> > <intent-filter> > <action android:name="android.intent.action.MAIN" /> > <category > android:name="android.intent.category.LAUNCHER" /> > </intent-filter> > </activity> > <activity android:name=".ActivityB"/> > </application> > </manifest> > > - - - - ActivityA.java - - - - > package foo.singletask; > > import android.app.Activity; > import android.content.ComponentName; > import android.content.Intent; > import android.os.Bundle; > import android.view.View; > import android.view.View.OnClickListener; > import android.widget.Button; > > public class ActivityA extends Activity > { > private OnClickListener gotoBClickListener = new > GotoBClickListener(); > private Intent gotoBIntent; > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.viewa); > Button button = (Button)findViewById(R.id.gotoB); > button.setOnClickListener(gotoBClickListener); > gotoBIntent = new Intent().setComponent( > new ComponentName(this, ActivityB.class)); > } > > private class GotoBClickListener implements OnClickListener { > @Override > public void onClick(View v) { > startActivity(gotoBIntent); > } > } > > } > > - - - - ActivityB.java - - - - > package foo.singletask; > > import android.app.Activity; > import android.os.Bundle; > > public class ActivityB extends Activity > { > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.viewb); > } > > } > > - - - - res/layout/viewa.xml - - - > <?xml version="1.0" encoding="utf-8"?> > <Button xmlns:android="http://schemas.android.com/apk/res/android" > android:id="@+id/gotoB" > android:layout_width="wrap_content" > android:layout_height="wrap_content" > android:textColor="#FF0000" > android:text="This is A - Go to B"/> > > - - - - res/layout/viewb.xml - - - > <?xml version="1.0" encoding="utf-8"?> > <TextView xmlns:android="http://schemas.android.com/apk/res/android" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > android:textColor="#FF0000" > android:text="hello from Activity B"/> > > On Feb 19, 6:36 am, Mark Wyszomierski <[email protected]> wrote: > > > > > Hi jotobjects, > > > Yes I am running it as you described, here it is exactly: > > > -Run emulator (same on g1 running 1.5) > > -Make sure all instances of app are killed (not running from eclipse) > > -Start app from app tray, ActivityA is created > > -ActivityA launched ActivityB via button click > > -Home button > > -Open app tray, click app icon > > -ActivityA is shown instead of ActivityB > > > are you sure you're getting different behavior? If so, it would be > > awesome if you could post your sample, this is definitely not desired > > behavior! > > > Thanks > > > On Feb 18, 1:57 pm, jotobjects <[email protected]> wrote: > > > > On quick inspection your app looks almost like the one I tested. My > > > test is with the emulator with Android 2.0.1. I am NOT running this > > > from eclipse. Any difference from your scenario? > > > > What do you mean by "resume" in your scenario? Do you mean pulling > > > down the tray and clicking on the App icon again? > > > > On Feb 18, 12:53 pm, Mark Wyszomierski <[email protected]> wrote: > > > > > Hi jotobjects, that would be really helpful if you could post your > > > > example. My simple example is below. Behavior I am seeing is: > > > > > -App Tray > > > > -ActivityA > > > > -btn click, start ActivityB > > > > -home button > > > > -resume > > > > -ActivityA is shown > > > > > import android.app.Activity; > > > > import android.content.Intent; > > > > import android.os.Bundle; > > > > import android.view.View; > > > > import android.view.View.OnClickListener; > > > > import android.widget.Button; > > > > > public class ActivityA extends Activity { > > > > @Override > > > > public void onCreate(Bundle savedInstanceState) { > > > > super.onCreate(savedInstanceState); > > > > setContentView(R.layout.activitya); > > > > > Button btn = (Button)findViewById(R.id.btn); > > > > btn.setOnClickListener(new OnClickListener() { > > > > public void onClick(View arg0) { > > > > Intent intent = new Intent(); > > > > intent.setClass(ActivityA.this, ActivityB.class); > > > > startActivity(intent); > > > > } > > > > }); > > > > } > > > > > } > > > > > import android.app.Activity; > > > > import android.os.Bundle; > > > > > public class ActivityB extends Activity { > > > > @Override > > > > public void onCreate(Bundle savedInstanceState) { > > > > super.onCreate(savedInstanceState); > > > > setContentView(R.layout.activityb); > > > > } > > > > > } > > > > > <activity android:name=".ActivityA" > > > > android:label="@string/app_name" > > > > android:launchMode="singleTask"> > > > > <intent-filter> > > > > <action android:name="android.intent.action.MAIN" /> > > > > <category android:name="android.intent.category.LAUNCHER" /> > > > > </intent-filter> > > > > </activity> > > > > > <activity android:name=".ActivityB" > > > > android:label="@string/app_name"> > > > > <intent-filter> > > > > <action android:name="android.intent.action.VIEW" /> > > > > <category android:name="android.intent.category.DEFAULT" /> > > > > </intent-filter> > > > > </activity> > > > > > Thanks > > > > > On Feb 18, 10:18 am, jotobjects <[email protected]> wrote: > > > > > > Just curious since you and others have asked similar questions in the > > > > > past. I just wrote a simple App with ActivityA and ActivityB where A > > > > > issingleTasklaunchMode. If I go A->b->Home->relaunch I get gack to > > > > > B. So I cannot replicate the scenario you describe. The code and all > > > > > files for the app are just a couple of dozen lines so I can post if > > > > > here if that would be helpful to figure out what you are doing > > > > > differently than my test. > > > > > > On Feb 18, 7:09 am, Mark Wyszomierski <[email protected]> wrote: > > > > > > > Hi, > > > > > > > I have an activity, ActivityA, and its launchMode is set to > > > > > > "singleTask". > > > > > > > I start the application from the app tray. ActivityA launches > > > > > > ActivityB from a button click. ActivityB is a normal activity with > > > > > > no > > > > > > launchMode set ("standard"). > > > > > > > With ActivityB on top of the activity stack, I hit the home button, > > > > > > then resume the app, I see ActivityA instead of ActivityB when > > > > > > resumed. > > > > > > > Shouldn't the history stack be preserved in this case, and B be > > > > > > showing? When I resume, I see A get onNewIntent() called, and I'm > > > > > > not > > > > > > sure why this is happening. I thought the stack would be preserved. > > > > > > > Thanks -- 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

