Differentiating between an Activity launch from home screen or from another activity from App
In the onCreate of your Activity, call getIntent()
. If the Activity is started from the launcher (home screen) the values for getAction()
will be android.intent.action.MAIN
and the getCategories()
will return a set which will contain the android.intent.category.LAUNCHER category.
If the activity is started from elsewhere these values may be null
.
In addition to @advantej's answer, you can extend each start-call to that activity adding an extra to the starting intent (e.g. intent.putExtra("caller", this.getClass().getSimpleName()
);
In the activity's onCreate
method you can check then what @advantej suggests.
If the initiator is not the home-screen icon, than you can check further if the intent.hasExtra("caller")
returns true, and if so, what is it.