是什么意图和正在申请的意图之间的确切区别?意图、确切、区别

2023-09-12 11:06:21 作者:别把浪说是自由

可能重复:   什么是待定意图是什么?

我感到困惑的的的意图的和的挂起的意图的。 谁能解释一下到底什么是两者之间的区别是什么?我搜索的SO,我发现这个链接,但它没有自己的需要满足:http://stackoverflow.com/questions/5633810/what-is-difference-between-an-intent-and-a-pending-intent.

I'm confused about intent and pending intent. Can anyone explain what exactly is the difference between both? I've searched on SO, I found this link but it didn't meet with my need: http://stackoverflow.com/questions/5633810/what-is-difference-between-an-intent-and-a-pending-intent.

我知道之前的意图是希望将开始以后。普通意图开始在它被传递给时startActivity(意向) StartService(意向)

i know Pending intent is an intent which will start later on. Normal intent is started at the time it is passed to startActivity(intent) or StartService(intent).

推荐答案

PendingIntent

的意图和目标的行动的说明来使用它进行。这个类的实例与getActivity(背景下,INT,意图,INT),getBroadcast(背景下,INT,意图,INT)的getService(背景下,INT,意图,INT)创建的;返回的对象可以被移交到其他应用程序,以便他们可以执行你在以后的时间说明代表你的行动。

A description of an Intent and target action to perform with it. Instances of this class are created with getActivity(Context, int, Intent, int), getBroadcast(Context, int, Intent, int), getService(Context, int, Intent, int); the returned object can be handed to other applications so that they can perform the action you described on your behalf at a later time.

通过向其他应用程序提供一个PendingIntent,你给予它执行您指定的操作,就好像其他应用程序是你自己(有相同的权限和身份)的权利。因此,你应该小心你是如何构建的PendingIntent:通常情况下,例如,基意图您提供将组件名称明确设置为自己的组件之一,以确保它最终送到那里,并没有其他地方。

By giving a PendingIntent to another application, you are granting it the right to perform the operation you have specified as if the other application was yourself (with the same permissions and identity). As such, you should be careful about how you build the PendingIntent: often, for example, the base Intent you supply will have the component name explicitly set to one of your own components, to ensure it is ultimately sent there and nowhere else.

一个PendingIntent本身只是一个参考,以通过描述用于检索它的原始数据系统进行维护的令牌。这意味着,即使其拥有的应用程序的过程中被杀死,在PendingIntent本身仍然可以使用从已被赋予它的其他程序。如果创建应用程序后重新检索同类PendingIntent的(同样的动作,同样的意图行动,数据,类别和组件,以及相同的标志),就会收到一个PendingIntent重新presenting同样的道理,如果这是尚有效的,因此可以调用取消()将其删除。

A PendingIntent itself is simply a reference to a token maintained by the system describing the original data used to retrieve it. This means that, even if its owning application's process is killed, the PendingIntent itself will remain usable from other processes that have been given it. If the creating application later re-retrieves the same kind of PendingIntent (same operation, same Intent action, data, categories, and components, and same flags), it will receive a PendingIntent representing the same token if that is still valid, and can thus call cancel() to remove it

意图

这是意图是要执行的操作的抽象描述。它可以与startActivity被用来发起活动,broadcastIntent将其发送给任何感兴趣的BroadcastReceiver的成分,和startService(意向)或bindService(意向,ServiceConnection,INT)与后台服务进行通信。

An intent is an abstract description of an operation to be performed. It can be used with startActivity to launch an Activity, broadcastIntent to send it to any interested BroadcastReceiver components, and startService(Intent) or bindService(Intent, ServiceConnection, int) to communicate with a background Service.

这是意图提供了一个工具,以便进行后期运行时的code在不同的应用结合。其最显著的用途是在活动中,在那里它可以被认为是活动间的粘合剂的启动。它基本上是将要执行的无源数据结构保持的动作的抽象描述。在意图主要部分信息是:

An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed. The primary pieces of information in an intent are:

动作   数据 - 这些数据进行操作,比如一个人的记录中的联系人数据库,EX pressed为URI

action -- The general action to be performed, such as ACTION_VIEW, ACTION_EDIT, ACTION_MAIN, etc. data -- The data to operate on, such as a person record in the contacts database, expressed as a Uri.