2012-01-05 116 views
1

当我得到一个新的任务时会弹出一个通知。点击该通知后,它会转到TestExList.java活动。Android通知点击

private void createNewTaskNotification(String s, String id) { 
    CharSequence title = "TASK"; 
    CharSequence message = s; 

    notificationManager = (NotificationManager) context 
      .getSystemService(Context.NOTIFICATION_SERVICE); 
    Notification notification = new Notification(R.drawable.checkyes, s, 
      System.currentTimeMillis()); 

    notification.flags = Notification.FLAG_AUTO_CANCEL; 

    notification.defaults |= Notification.DEFAULT_SOUND; 
    notification.defaults |= Notification.DEFAULT_VIBRATE; 

    Intent notificationIntent = new Intent(context, TestExList.class); 
    notificationIntent.putExtra("EmpID", Functions.getLoginEmpID(context)); 
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 
      Integer.parseInt(id), notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); 

    notification.setLatestEventInfo(context, title, message, pendingIntent); 
    notificationManager.notify(Integer.parseInt(id), notification); 
} 

它的工作方式是,如果我在另一个屏幕上,单击通知将我带到TestExList.java。

如果我在同一个屏幕上(TestExList.java),它不会加载该页面。我想刷新该页面,以便我可以在该页面上看到我的新任务。

我做错了什么?

+0

这实际上帮助我解决了我的通知来自Google推送服务的问题。欢呼 – wired00 2013-05-03 04:04:57

回答

1

删除此行

notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 

此行弹出从活动组活动,如果活动存在,否则创建活动的新实例,希望这有助于。

+0

It W O R K E D !!!谢谢。 – user1128578 2012-01-05 15:42:42