views:

113

answers:

1

I have the following code that creates a notification when an SMS message is received by the phone. It displays the notification correctly; however, when the user clicks the notification, nothing happens. It should open up the SMS inbox so the user can view their message. Thanks in advance.

mNotificationManager = (NotificationManager) arg0.getSystemService(Context.NOTIFICATION_SERVICE);
Uri uri = Uri.parse("content://sms/inbox");
PendingIntent contentIntent = PendingIntent.getActivity(arg0, 0, new Intent(Intent.ACTION_VIEW, uri), Intent.FLAG_ACTIVITY_NEW_TASK);
String tickerText = arg0.getString(R.string.newmsg, msgs[i].getMessageBody().toString());
Notification notif = new Notification(R.drawable.icon, tickerText, System.currentTimeMillis());
notif.setLatestEventInfo(arg0, msgs[i].getOriginatingAddress(), msgs[i].getMessageBody().toString(), contentIntent);
notif.vibrate = new long[] { 100, 250, 100, 500 };
mNotificationManager.notify(R.string.recv_msg_notif_id, notif);
+1  A: 

I got it to work. The following code shows how to accomplish this task:

Intent notificationIntent = new Intent(Intent.ACTION_MAIN);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
notificationIntent.setType("vnd.android-dir/mms-sms");
trpsbill