How to determine if Android App open from Notification message?
You need to use putExtra(ID_KEY,id)
when you create your Intent
for starting your application, and in your onCreate()
method you can use getIntent().getExtras().getInt(ID_KEY);
to retrieve your passed id integer
.
The Start Activity code would be like this, otherwise after once it comes from GCM notification, from then every time the Activity comes from the Recent list, it will say it comes from GCM notification, which is wrong.
Intent intent = this.getIntent();
if (intent != null && intent.getExtras() != null && intent.getExtras().containsKey("JOBID") && (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
int jobID = this.getIntent().getExtras().getInt("JOBID");
if (jobID > 0) {
}
}