Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can my Android app detect if it was launched from Eclipse?

Is there a way for an Android activity to detect how it was launched? Specifically, I would like to detect if my app was started from Eclipse, versus if it was started normally (e.g., from the home screen or installed application list).

This is a proxy for knowing if crash reports should be uploaded or not. I'm assuming if Eclipse launched the app, then I don't need to uploaded crashes, because I'm already debugging the app, but if the same build of the app is started "normally", I'd like to upload any exceptions.

This is just to make my personal debugging and development easier, so unshippable hacks or tweaks to Eclipse are useful to me.

like image 296
P.T. Avatar asked Jul 10 '13 00:07

P.T.


People also ask

How do I find out when an app was installed for the first time?

Navigate to APPS and select the app u want by long press. And then hit the Info button on top right corner. Thats it , it will show u the modified or installed time.

How do I find my first app launch Android?

There's no reliable way to detect first run, as the shared preferences way is not always safe, the user can delete the shared preferences data from the settings! a better way is to use the answers here Is there a unique Android device ID? to get the device's unique ID and store it somewhere in your server, so whenever ...


1 Answers

This method appears to do what you require:

if(!android.os.Debug.isDebuggerConnected()) {
    // Send report...
}

This should tell you if you're currently attached to a debugger. If launched from the app drawer or a homescreen shortcut, you won't be attached (unless you already have a running instance that is attached) and this method will return false - in this case you can upload your crash information.

like image 196
Adam S Avatar answered Sep 26 '22 12:09

Adam S