2015-06-27 234 views
3
執行的PendingIntent
Android setFullScreenIntent() execute the PendingIntent when notification reach and phone is locked. 

奇怪的問題,我用setFullScreenIntent()時,它會執行時,我的手機被鎖定,我已經設置爲內容的PendingIntent,當我解開我的手機,然後對着應用程序已打開。如果手機解鎖並收到通知,則會在所有屏幕上顯示通知,並且不執行PendingIntent。有人遇到這個問題嗎?您的建議將不勝感激。的Android setFullScreenIntent()時,通知到達和手機被鎖定

下面是我的代碼

Intent _intent = new Intent(GcmIntentService.this,NotificationActivity.class); 
_intent.addCategory(Intent.CATEGORY_DEFAULT); 
_intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

mNotificationManager =(NotificationManager)GcmIntentService.this.getSystemService(Context.NOTIFICATION_SERVICE); 

PendingIntent contentIntent = PendingIntent.getActivity(GcmIntentService.this, requestCode, 
        _intent, PendingIntent.FLAG_UPDATE_CURRENT); 

Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); 
builder = new NotificationCompat.Builder(this) 
       .setSmallIcon(R.drawable.ic_launcher) 
       .setLargeIcon(icon) 
       .setTicker(ticker) 
       .setContentTitle(title) 
       .setContentText(content) 
       .setAutoCancel(true) 
       .setWhen(System.currentTimeMillis()) 
       .setDefaults(Notification.DEFAULT_ALL) 
      .setContentIntent(contentIntent); 

     if(CURRENT_VERSION>=LOLLIPOP_VERSION){ 
      builder.setColor(Color.argb(255, 117,63,0)); 
      builder.setVisibility(Notification.VISIBILITY_PUBLIC); 
      builder.setSmallIcon(R.drawable.app_notification_icon); 
builder.setFullScreenIntent(contentIntent, false); 

      } 
mNotificationManager.notify(NOTIFICATION_ID, builder.build()); 

回答

5

,如果你不想EXCUTE開啓鎖屏上,你應該設置的PendingIntent空和高優先級必須setFillScreenIntent(的PendingIntent,高優先級)

builder.setFullScreenIntent(null, true); 
是真實的

它正在工作

1

如果您不想在達到通知時執行FullScreen Intent,只需將空PendingIntent設置爲FullScreen Intent即可。

PendingIntent fullScreenIntent = PendingIntent.getActivity(GcmIntentService.this, requestCode, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT); builder.setFullScreenIntent(fullScreenIntent, true);