Lock screen notification automatically releases lock when it is tapped

75 views Asked by At

I am trying to make lock screen notification that asks users to release its lock when it is clicked. Notification using NotificationCompat.builder works fine with lock screen of pins, patterns and password. But when lock screen is set with dragging, tapping notification automatically releases device's lock and do the work right away, not asking users to drag for releasing its lock. My code looks like below

mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
mBuilder = new Notification.Builder(mContext).setSmallIcon(R.drawable.indicator_icon);
Notification noti = mBuilder.build();
mNotificationManager.notify(NOTIFICATION_ID, noti);  

I tried depreciated API Noficiation() like below

Notification notification = new Notification();
notification.icon = R.drawable.indicator_icon; 
mNotificationManager.notify(NOTIFICATION_ID, noti);

This works fine! (It asks dragging for linking to my application even when screen is locked by simple dragging)

So I guess there is a difference between two codes above. I cannot use notification since I need to set remote view.

The thing is the first code also works well on some devices like Galaxy S5, but not on the other devices like Galaxy Note 4. On the Galaxy S5, it does not release its lock by itself, but a little UI difference is made when I tap the notification.(such as not showing clock or other notifications)

Could anyone give me some advice?

1

There are 1 answers

0
Sung Eun Park On BEST ANSWER

I solved it! The problem was setting pending intents on the remote view not builder itself. Both works, but they act differently in the different settings of all kinds of devices. I guess it is safer to set pendingIntents on the builder itself, not the remoteview...