Pratik Pratik - 1 year ago 190
Android Question

Android setFullScreenIntent() execute the PendingIntent when notification reach and phone is locked

Android setFullScreenIntent() execute the PendingIntent when notification reach and phone is locked.


Strange issue facing when I using
setFullScreenIntent()
it will execute the
PendingIntent
which I have set as content when my phone is locked and when I unlocking my phone then app is opened. If phone is unlocked and notification received it'll be display notification as top on all screen and not execute the
PendingIntent
. Has anybody face this issue? Your suggestion will be appreciated.

Below is my code

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

Answer Source

if you don't want to excute on open lock screen, you should set PendingIntent null and highPriority must be true in setFillScreenIntent(PendingIntent,highPriority)

builder.setFullScreenIntent(null, true);

It's working

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download