Yes, a singleTask or singleInstance launch mode for your Activity sounds
right:
http://developer.android.com/guide/topics/fundamentals.html#lmodes
I *think* your intent for the notificaiton is wrong: does
"MyApplication.class" refer to your main activity, or to your
application class? It should be the activity class, also make sure
you've added it to the manifest.
-- Kostya
25.01.2011 20:50, Wall-E пишет:
I have created a notification when receiving an SMS and I would like
my application to either launch OR if it has already been launched to
return to the last activity the user left it. I tried reading up on
Activities and Tasks and the flags associated with it but it did not
help me much. I tried the code described below but it doesn't do
anything when clicking on notification.
Currently I have set the launchMode to singleTask but am not sure if
that is what I want to reach the desired behavior mentioned above, can
anybody clarify?
Also, creating the intent to pass into the PendingIntent is confusing
me too. This is what I have so far:
Context context = getApplicationContext();
Intent openMyAppIntent = new Intent(context, MyApplication.class);
showNotification(openMyAppIntent, "SMS Encounter", "Received SMS",
msg, R.drawable.icon);
this is showNotification:
private void showNotification(Intent intent, String message, String
messageHeadline, String messageDetails, int icon)
{
NotificationManager mNotificationManager =
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notifyDetails = new Notification(icon, message,
System.currentTimeMillis());
PendingIntent myIntent =
PendingIntent.getActivity(getApplicationContext(), 0, intent, 0);
notifyDetails.setLatestEventInfo(getApplicationContext(),
messageHeadline, messageDetails, myIntent);
notifyDetails.flags |= Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(ID, notifyDetails);
}
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en