How to detect if an app is opened from custom url or notification - android -


i'm working on app in android. can opened both custom url , notification (when user clicks on it). i've learned how both , know working correctly. want know how can detect when it's open url , when notification (it has difference when handle in main activity).

thanks help!

it pretty simple. set boolean in intent , when activity opened check if opened custom url or notification.

let's setting intent notification following, put in intent:

intent intent = new intent(context, mainactivity.class);  intent.putextra("is_from_notification",true); 

in oncreate method of activity check value

@override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);       boolean isfromnotification = getintent().getbooleanextra("is_from_notification",false);  } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -