我正在处理我知道如何通过意图打开活动的活动,但我想知道如何通过intent-filter打开活动以及intent-filter打开活动的作用是什么。
甚至可以通过IntentFilter启动活动试试这个
基本上,当您安装应用程序时,Android系统将使用相应的操作注册活动,当您使用自定义操作声明活动时,Android系统会将活动与相应的活动一起存储。使用自定义操作启动intent时。系统将找到接收活动并启动它,只有一个活动与之匹配,如果有多个活动接收到该动作,系统将要求用户选择完成操作的活动。
在activity
宣布manifest
为
<activity
android:name=".YourActivity" >
<intent-filter>
<action android:name="your.custom.ACTION" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
那么你可以通过调用来启动这个活动
startActivity(new Intent("your.custom.ACTION"));
IntentFilter与BroadcastReceivers一起使用。然后,当任何适合通过过滤器的意图到达系统时,BroadcastReceiver将被激活。
这通常用于在活动之间,不同应用程序之间或从服务器到应用程序之间发送消息。
请参阅BroadcastReceiver文档:http://developer.android.com/reference/android/content/BroadcastReceiver.html
或者本教程:http://www.vogella.com/tutorials/AndroidBroadcastReceiver/article.html