微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

双击在设备锁定时点击通知不会在设备解锁时打开预期的活动

如何解决双击在设备锁定时点击通知不会在设备解锁时打开预期的活动

第一次发帖,这里的老读者。我遇到了一个特定的问题,我在这里没有看到。所以我收到了一个用下面的代码构建的通知

**Intent intent = new Intent(this,SingleEmailActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,100,intent,PendingIntent.FLAG_UPDATE_CURRENT);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP
           | Intent.FLAG_ACTIVITY_CLEAR_TOP);
 NotificationCompat.Builder builder = new NotificationCompat.Builder(this,CHANNEL_ID)
                .setSmallIcon(R.mipmap.important)
                .setContentTitle(title)
                .setContentText(text)
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .setAutoCancel(true)
                .setContentIntent(pendingIntent);
        
            notificationmanagerCompat notificationmanager = notificationmanagerCompat.from(this);
            notificationmanager.notify(notID,builder.build());**

当手机解锁并且我点击状态栏中的通知图标时,它会按预期工作(SingleEmailActivity 已启动)。但是当我在设备锁定时单击通知时,解锁时不会启动该活动。

以下是 Manifest 中的活动

<activity android:name=".SingleEmailActivity"
            android:screenorientation="portrait"
            android:launchMode="singletop"
            ></activity>

当我将 (android:showWhenLocked="true") 行添加到清单时,显示的活动没有解锁的 nedd,但我打算让活动在解锁时启动。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。