How to find whether app is running in background or foreground or killed android -


i need suggestion guyzz that, in application using gcm broadcast receiver , , app having pin page also. here need check condition either user logged in or not when ever push notification comes, depends upon need set different activities . can suggest me how solve this?? sorry english.

you can followed:

when app not started/ running , start notification, oncreate gets called.

@override protected void oncreate(bundle savedinstancestate) {    super.oncreate(savedinstancestate); } 

when app running (background or foreground), , start new intent notification method gets called: (if using singletop)

@override protected void onnewintent (intent intent){  } 

to detect whether app running back- or foreground, can set boolean in onpause/onresume:

@override protected void onresume() {   super.onresume();   runningonbackground = false; }  @override protected void onpause() {   super.onpause();   runningonbackground = true; } 

hope helps!


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -