I developed a small android application and recently discovered a strange behavior.
When I navigate to an arbitrary Activity after installing this app using usb and eclipse I can leave the app, go to the android home screen or another application and then return to the mentioned arbitrary Activity directly by "starting" the application again.
But when I install the application on the phone directly by downloading the apk-file, I will always return to the root Activity of the application when I return to this app, after I switched to another application or the android home screen.
Does anybody know where this behavior comes from or how I can fix this issue?
UPDATE: I run the application on real hardware in both cases.
putting the following code to the root Activity fixed this issue finally.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
// Activity was brought to front and not created,
// Thus finishing this will get us to the last viewed activity
finish();
return;
}
}
source: App always starts fresh from root activity instead of resuming background state (Known Bug)
place in your manifest
file android:launchMode="standard"
for that particular activity
for which you want to display only once.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With