2013-08-23 3 views

답변

4

통지 용 PendingIntent를 작성하는 데 사용하는 의도에 extra을 넣을 수 있습니다. official guide에서

:

// Instantiate a Builder object. 
NotificationCompat.Builder builder = new NotificationCompat.Builder(this); 
// Creates an Intent for the Activity 
Intent notifyIntent = 
     new Intent(new ComponentName(this, ResultActivity.class)); 
// Sets the Activity to start in a new, empty task 
notifyIntent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK); 
// Creates the PendingIntent 
PendingIntent notifyPendingIntent = 
     PendingIntent.getActivity(
     this, 
     0, 
     notifyIntent 
     PendingIntent.FLAG_UPDATE_CURRENT 
); 

// Puts the PendingIntent into the notification builder 
builder.setContentIntent(notifyPendingIntent); 
// Notifications are issued by sending them to the 
// NotificationManager system service. 
NotificationManager mNotificationManager = 
    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
// Builds an anonymous Notification object from the builder, and 
// passes it to the NotificationManager 
mNotificationManager.notify(id, builder.build()); 

간단히 내가 확인 플래그가 설정된했습니다,

+0

notifyIntent.putExtra("fromNotification", true); 감사합니다 추가 –

4

의도를 정의 할 때 알림에 부울 플래그를 추가로 추가합니다. 그런 다음 주요 활동 시작에서 인 텐트에 추가가 포함되어 있는지 확인하십시오.

관련 문제