623得票18回答
什么是Android PendingIntent?

我已经阅读了Android文档,但我仍需要更多的解释。那么,PendingIntent到底是什么?

252得票22回答
如何解决安卓API 30+中的“Missing PendingIntent mutability flag”警告?

当我将目标SDK更新到30+(即Android R或更高版本)时,当我想要定义PendingIntent时,我的PendingIntent.FLAG_UPDATE_CURRENT标志出现了一个lint警告Missing PendingIntent mutability flag。 我该如何处理...

218得票11回答
从Activity外部调用startActivity()?

我正在使用AlarmManager来触发广播信号的intent。以下是我的代码:AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(this, Wake...

149得票7回答
通知传递旧的意图扩展信息

我正在通过以下代码在BroadcastReceiver中创建一个通知:String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManage...

147得票4回答
PendingIntent无法发送Intent附加信息

我的MainActivity使用带有名为isNextWeek的boolean额外参数的Intent启动RefreshService。 RefreshService创建一个Notification,当用户单击它时会启动我的MainActivity。 效果如下: Log.d("Refre...

144得票8回答
意图 - 如果活动正在运行,则将其置于前台,否则启动一个新的活动(来自通知)

我的应用程序有通知功能,但是如果没有任何标志,每次都会启动新的活动,导致多个相同的活动在彼此之上运行,这显然是错误的。我希望它能够将通知挂起的意图中指定的活动放在前台,如果已经在运行,则将其置于前台;否则启动它。到目前为止,我使用的通知意图/挂起意图是:private static Pendi...

141得票5回答
"requestCode"在PendingIntent中有什么用途?

背景: 我正在使用AlarmManager通过PendingIntent设置定时器。 问题: 起初,我认为要取消先前的定时器,必须提供之前用于启动定时器的确切requestCode。 但后来我发现我错了,因为取消API说: 删除任何具有匹配意图的警报。任何类型的任何警报, ...

98得票14回答
PendingIntent对第一条通知的处理正确,但对其余通知的处理不正确

protected void displayNotification(String response) { Intent intent = new Intent(context, testActivity.class); PendingIntent pendingInten...

98得票5回答
如何在安卓系统中通过编程的方式移除通知栏中的通知?

如何使用PendingIntent编程方式移除应用程序的通知?我已经使用以下方法来取消通知:AlarmManager am=(AlarmManager)getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(Dis...

90得票3回答
获取AlarmManager中处于活动状态的PendingIntent列表

有没有一种方法可以获取设备中活动的PendingIntent列表? 我开始使用AlarmManager,我想查看我的PendingIntent是否已正确创建和删除。 还可以通过好奇心查看其他存在的PendingIntent,看看某些应用程序是否在执行一些“额外的工作”。