Pra*_*tik 5 notifications android
Android setFullScreenIntent() execute the PendingIntent when notification reach and phone is locked.
Run Code Online (Sandbox Code Playgroud)
当我使用setFullScreenIntent()它时面临的奇怪问题将PendingIntent在我的手机被锁定时执行我设置的内容,当我解锁手机时,应用程序将被打开.如果手机已解锁并收到通知,则显示通知将在所有屏幕上显示为顶部而不执行PendingIntent.有人面对这个问题吗?您的建议将不胜感激.
以下是我的代码
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());
Run Code Online (Sandbox Code Playgroud)
小智 5
它不适用于我的Android 8.1.如果将intent设置为null,它将成为正常通知,而不会持续超过抬头区域.
builder.setFullScreenIntent(null, true);
Run Code Online (Sandbox Code Playgroud)