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

答えて

1

削除このライン

notificationIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 

活動が存在する場合、この行は、アクティビティスタックから活動をポップアップするには、そうでない場合は、活動の新しいインスタンスを作成し、このことができます願っています。

+0

それはW O R K E D !!!ありがとう。 – user1128578