I have an Android application with the following logic of activities execution:
if FIRST_RUN: SplashScreeen -> Logon -> MainScreenTabHost
if PUSH:
Not Running: SplashScreeen -> Logon -> MainScreenTabHostRunning:MainActivityreceives a message
I can’t figure out how to achieve this. My source code for NotificationBar item:
Notification notif = new Notification(R.drawable.ic_launcher, "Text in status bar",
System.currentTimeMillis());
Intent intent = new Intent(this, MainScreenTabHost.class);//HERE PROBLEM
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
notif.setLatestEventInfo(this, "Notification's title", "Notification's text", pIntent);
notif.flags |= Notification.FLAG_AUTO_CANCEL;
this.notificationManager.notify(1, notif);
This code always runs application MainScreenTabHost, but if application is not running it makes some init in Logon screen.
My question is: How can I check that application is running and if it’s not then create an Intent to run Splash screen and cycle for FIRST RUN? On the other hand, if application is running I just want to send an Intent (maybe a Broadcast) for some operations.
And one thing, my service is not always running because it is run by a broadcast intent from Push Notification.
Hm, i found next solution:
So trick is: when fired onMessage method i check what activity currently on Top and if it’s part of mine – i just send broadcast to it. If NOT a show notification with SplashScreen intent.