ashiaka
ashiaka

Reputation: 4064

How can I make an android app stop restarting every time it is opened?

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.

Upvotes: 4

Views: 2448

Answers (2)

Avadhani Y
Avadhani Y

Reputation: 7636

place in your manifest file android:launchMode="standard" for that particular activity for which you want to display only once.

Upvotes: 5

Kazekage Gaara
Kazekage Gaara

Reputation: 15052

This is because of the way the system handles the application.

It is entirely upto the system to destroy your application upon the needs of other applications.

When you run it on your emulator, it does not destroy your application and hence, you resume from the same Activity you left.

But when you run it on your device, the device might feel that the memory occupied by the application needs to be freed up, and hence destroys the application. And the next time you start, it starts it from the beginning.

Upvotes: 1

Related Questions