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

问题描述

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

**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 (将#修改为@)