- Home /
Open Android App by clicking on Notification
I use Google Cloud Messaging to send Notficitations to my app. If my app is in foreground i just want to silently call a methode in unity from my service, else i want to start my app by clicking on the notification. I googled and found out to determinate if my app runs in foreground with:
public boolean isForeground(String myPackage){
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List< ActivityManager.RunningTaskInfo > runningTaskInfo = manager.getRunningTasks(1);
ComponentName componentInfo = runningTaskInfo.get(0).topActivity;
if(componentInfo.getPackageName().equals(myPackage)) return true;
return false;
}
So, what do I need to pass as the myPackage parameter? A standard unity package parameter or acctually my package name? I know I can call methodes in Unity from Android with the UnityPlayer class But how can I start my app if its dont even running or putting in back into foreground if its in background?
Update: Just a little update: This methode dont work. It just returns true if myPackage equals the package of my class, and not unity, so in the end, I dont get any new infromation.
Hey. Were you able to figure this out? I'm trying to run my app when user clicks on a notification.
Your answer
Follow this Question
Related Questions
Unity wont install on android device 1 Answer
Multiple Cars not working 1 Answer
Unity 4 Android Game cannot access SQLite DB (C# Script) 1 Answer
Distribute terrain in zones 3 Answers