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());