Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to awake already running app after c2dm message on android
    primarykey
    data
    text
    <p>is there a way to awake already running app from the notification bar after c2dm message? i have this app that is registered with c2dm servers that receives push notifications from my server to do some processing. so after i receive c2dm message from my server, it displays the status bar notification to the user, user expands the notifications and clicks on my app, brings it up. </p> <p>all is good but if this app was already running before (stared from the icon) this would load another instance of my app into memory. also some of the things are crashing in it. i already changed the <code>android:launchMode="singleTop"</code> on all my activities, i tried using <code>intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)</code> in my notification and no luck. i always end up with 2 apps running.</p> <p>any help is appreciated</p> <p>here my static function that i use to create a notification after i receive the c2dm message:</p> <pre><code>public static void notifyStart(Context context, String notificationText) { //notification String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); int icon = R.drawable.icon_notify; CharSequence tickerText = notificationText; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); notification.ledARGB = 0xff00ff00; notification.ledOnMS = 400; notification.ledOffMS = 400; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.defaults |= Notification.DEFAULT_SOUND; CharSequence contentTitle = "App Name"; CharSequence contentText = notificationText; Intent notificationIntent = new Intent(context, home.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); mNotificationManager.notify(1350, notification); } </code></pre> <p>and here is my home activity:</p> <pre><code> &lt;activity android:name=".home" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar" android:launchMode="singleTop" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload