Shant
Shant

Reputation: 185

Android application restarts when USB device is plugged in

For anyone who can help me: I am currently working with the open accessory framework for Android 3.1+ and my application runs when the usb device is plugged in automatically. However during the event that I unplug and replug the usb while the application is running, android will run a new instance of my application on top of the current one that is already open. How can I keep android from opening another copy of my application that is already currently running? Thanks

Upvotes: 1

Views: 2813

Answers (1)

Huang
Huang

Reputation: 4842

set android:launchMode="singleTask" attribute for your root activity. this will ask the OS to bring the root activity to foreground if it is running, instead of create a new instance.

see here :http://developer.android.com/guide/topics/manifest/manifest-intro.html

Upvotes: 3

Related Questions