我阅读了Android文档,但我仍然需要更多的说明。PendingIntent到底是什么?


当前回答

In an easy language, 1. A description of an Intent and Target action to perform. First you have to create an intent and then you have to pass an specific java class which you want to execute, to the Intent. 2. You can call those java class which is your class action class by PendingIntent.getActivity, PendingIntent.getActivities(Context, int, Intent[], int), PendingIntent.getBroadcast(Context, int, Intent, int), and PendingIntent.getService(Context, int, Intent, int); Here you see that Intent which is comes from the step 1 3. You should keep in mind that...By giving a PendingIntent to another application, you are granting it the right to perform the operation you have specified.

这是我读了很长时间后学到的。

其他回答

简单来说

悬而未决的意图基本上是一种意图,你可以传递给其他应用程序或服务,如通知管理器,警报管理器等,让他们处理何时是正确的时间/行为执行。

一个PendingIntent用一个令牌包装了一般的Intent,你给外部应用程序执行你的许可。 如:

你的音乐应用程序的通知不能播放/暂停音乐如果你 没有给PendingIntent发送广播,因为你的音乐应用 哪个通知应用程序具有READ_EXTERNAL_STORAGE权限 不喜欢。通知是一个系统服务(所以它是一个外部应用程序)。

未决意图是一个令牌,你给一些应用程序执行你的应用程序的代表,不管你的应用程序进程是否活跃。

我认为文件是足够详细的: 未决的意图文档。

只要想想Pending Intents的用例(broadcast Intents, scheduling alarms),文档就会变得更加清晰和有意义。

顾名思义…PendingIntent

你可以过一段时间再做。这是另一个意图。它是一种将你的任务交给其他应用程序来执行的方式。

一个PendingIntent是一个令牌,你给一个外部应用程序(例如NotificationManager, AlarmManager, Home Screen AppWidgetManager,或其他第三方应用程序),它允许外部应用程序使用你的应用程序的权限来执行预定义的代码段。

如果你给了外部应用一个Intent,它会用自己的权限执行你的Intent。但是如果你给了外部应用一个PendingIntent,该应用将使用你的应用权限执行你的Intent。