IntentFilter使用
16lz
2021-01-23
一直对于处于不同的application的activity的调用,心存疑虑。
昨天,使用intent的隐式调用进行了实现。
首先,建立一个android 工程,就比如HelloWorld程序,只需要在该activity下加入属性:
<intent-filter>
<action android:name="com.able.test.aaa"></action>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
,再建立一个android工程,我们就称之为Test,只需要在里面使用:
Intent intentA = new Intent("com.able.test.aaa");
intentA.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(intentA);
就可以成功调用HelloWorld程序的那个加入了intent-filter的activity。
昨天,使用intent的隐式调用进行了实现。
首先,建立一个android 工程,就比如HelloWorld程序,只需要在该activity下加入属性:
<intent-filter>
<action android:name="com.able.test.aaa"></action>
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
,再建立一个android工程,我们就称之为Test,只需要在里面使用:
Intent intentA = new Intent("com.able.test.aaa");
intentA.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(intentA);
就可以成功调用HelloWorld程序的那个加入了intent-filter的activity。
更多相关文章
- cocos2dx程序 在android上 触碰屏幕就崩溃 crash in cocos on to
- Android stdio调试程序闪退或者报错:"xxx keeps stopping"解决方
- ANDROID应用程序的混淆打包
- android 锁屏时,不运行锁屏程序
- [摘]Android如何将程序打成jar包
- android里在程序中修改listView里的内容
- Android 开机自启动示例程序
- 如何使用arm-eabi-gdb调试android c/c++程序