2012-01-05 109 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