activity 中的 Intent 过滤器和广播接收器有什么区别?
What is the difference between intent filter in activity and broadcast receiver?
谁能告诉我什么时候应该使用 Intent 过滤器和广播接收器?
<activity>
<intent-filter></intent-filter>
</activity>
和
<receiver>
<intent-filter></intent-filter>
</receiver>
A broadcast receiver is a component that responds to system-wide
broadcast announcements. Many broadcasts originate from the system—for
example, a broadcast announcing that the screen has turned off, the
battery is low, or a picture was captured. Applications can also
initiate broadcasts—for example, to let other applications know that
some data has been downloaded to the device and is available for them
to use. Although broadcast receivers don't display a user interface,
they may create a status bar notification to alert the user when a
broadcast event occurs. More commonly, though, a broadcast receiver is
just a "gateway" to other components and is intended to do a very
minimal amount of work. For instance, it might initiate a service to
perform some work based on the event.
您可以通过两种方式使用广播接收器。
1) 在您的 activity.When 中注册和注销 您在您的 activity 中注册 您需要传递一个动作,它会注意它,当我们发送广播时它会触发我们应用程序的操作。
2) 使用广播接收者在清单文件中注册并在清单文件中的意图过滤器中提及操作的第二种方法。
Intent 过滤器简单来说就是"It is filter just we use in our usual lives." 它将过滤调用它的操作。
Intent 过滤器与 activity 和广播相同 receiver.Its 主要功能是过滤 action.It 取决于我们如何利用 it.One 主要示例在我们的每个清单文件中的应用程序我们指定
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
在我们的启动器 activity.It 中建议这个 activity 是我们的启动器 activity 并且会 运行 首先在我们的 application.If 开始时你不指定它然后您的应用程序不会 launch.Also 我们无法在广播接收器的意图中指定这些类型的过滤器 filter.They 不是应用程序的启动器,
我认为您对隐式意图和广播接收器感到困惑。 Activity中的Intent Filter用于接收隐含的intent,Receiver中的Intent Filter用于接收广播。 OS 向所有接收者发送广播消息,同时向特定接收者发送隐式意图 activity。参见 here
谁能告诉我什么时候应该使用 Intent 过滤器和广播接收器?
<activity>
<intent-filter></intent-filter>
</activity>
和
<receiver>
<intent-filter></intent-filter>
</receiver>
A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Applications can also initiate broadcasts—for example, to let other applications know that some data has been downloaded to the device and is available for them to use. Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is just a "gateway" to other components and is intended to do a very minimal amount of work. For instance, it might initiate a service to perform some work based on the event.
您可以通过两种方式使用广播接收器。
1) 在您的 activity.When 中注册和注销 您在您的 activity 中注册 您需要传递一个动作,它会注意它,当我们发送广播时它会触发我们应用程序的操作。
2) 使用广播接收者在清单文件中注册并在清单文件中的意图过滤器中提及操作的第二种方法。
Intent 过滤器简单来说就是"It is filter just we use in our usual lives." 它将过滤调用它的操作。
Intent 过滤器与 activity 和广播相同 receiver.Its 主要功能是过滤 action.It 取决于我们如何利用 it.One 主要示例在我们的每个清单文件中的应用程序我们指定
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
在我们的启动器 activity.It 中建议这个 activity 是我们的启动器 activity 并且会 运行 首先在我们的 application.If 开始时你不指定它然后您的应用程序不会 launch.Also 我们无法在广播接收器的意图中指定这些类型的过滤器 filter.They 不是应用程序的启动器,
我认为您对隐式意图和广播接收器感到困惑。 Activity中的Intent Filter用于接收隐含的intent,Receiver中的Intent Filter用于接收广播。 OS 向所有接收者发送广播消息,同时向特定接收者发送隐式意图 activity。参见 here