views:

40

answers:

1

Hi,

I have an android background Service that will occasionally post a notification to the Status Bar using the Notification class. Occasionally, when I receive a notification, pull-down the notification window, and select the notification from the list, the specified Activity doesn't start. When this happens, the screen dims (as if it were about to display the Activity), but the Activity is never shown. I included my code below. Any ideas?? Thanks!


private NotificationManager  m_nm;
private RemoteViews          m_contentView;

onCreate()
{
   ...
   m_nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
   m_contentView = new RemoteViews(getPackageName(), R.layout.custom_notification_layout);
   ...
}

disaplyNote(int uniqueID, String text)
{
   Notification note = new Notification( R.drawable.status_icon, text, System.currentTimeMillis() );
   note.flags |= Notification.FLAG_AUTO_CANCEL;
   note.defaults |= Notification.DEFAULT_SOUND;
   note.defaults |= Notification.DEFAULT_VIBRATE;
   note.defaults |= Notification.DEFAULT_LIGHTS;

   Bundle b = new Bundle();
   b.putString("NoteText", text);

   Intent i = new Intent(this, UserNotification.class);  
   i.putExtras(b);
   i.setAction("" + uniqueID);
   i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);

   m_contentView.setTextViewText(R.id.CustomNotificationText, text);
   note.contentView = m_contentView;
   note.contentIntent = pi;
   m_nm.notify(uniqueID, note);   
}

NOTE: The UserNotification class extends Activity, and is set to a dialog theme in the manifest. This class also has its taskAffinity property set to "" in the manifest.

A: 

Any suggestions for this issue?

Jim