Have you set up a broadcast receiver to monitor for an incoming sms in your
manifest?

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Wall-E
Sent: Tuesday, January 25, 2011 12:50 PM
To: Android Developers
Subject: [android-developers] notification help

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);

}

--
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

-- 
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

Reply via email to