且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

点击通知不启动活动

更新时间:2022-12-19 18:41:21

在使用Notification.Builder以上的Andr​​oid 3.0或NotificationCompat.Builder支持库V4作为@Raghunandan暗示的评论,我有同样的问题顶部一个可能的共同解决您的问题。

On top of using Notification.Builder for above Android 3.0, or NotificationCompat.Builder in support library v4 as @Raghunandan suggests in the comment, I had the same problem with a possible common solution to your problem.

这是特定于4.4,如下所示:发行63236 :与TaskStackBuilder.getPendingIntent()通知没有打开活动这里的问题61850:奇巧通知操作待定意向后,无法继续应用程序重新安装

This is specific to 4.4 as seen here:Issue 63236:Notification with TaskStackBuilder.getPendingIntent() is not open the Activity and here Issue 61850: KitKat notification action Pending Intent fails after application re-install

一个确认的解决方案是执行取消()操作上相同的PendingIntent与一个你将要创建。

One confirmed solution is to perform cancel() operation on an identical PendingIntent with the one you are about to create.

什么工作对我来说是修改目标的活动清单定义,并添加 安卓出口=真正的中的活动标签为目标的活动。这将是MainActivity你的情况我想。

What worked for me was to modify the target Activity's manifest definition and add android:exported="true" within "activity" tags for the target Activity. That would be MainActivity in your case I assume.

例如:

<activity
        android:name="com.your.MainActivity"
        android:exported="true" >
.
.
</activity>