Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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());
like image 489
Pratik Avatar asked Jun 27 '15 07:06

Pratik


1 Answers

It's not working on my Android 8.1. If set the intent to null, it will become the normal notification without persist over heads-up area.

builder.setFullScreenIntent(null, true);
like image 75
manish thanki Avatar answered Nov 07 '22 03:11

manish thanki