IntentFilter使用
16lz
2022-04-09
一直对于处于不同的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。
更多相关文章
- Unity与Android接口互相调用
- android 资源res下目录使用
- Listview 选项按下去黑了所有按钮的解决方法 ——android:cacheC
- Android(安卓)support library 23.2新特性介绍
- 【Android(安卓)+ Java】简便的异步Http连接框架
- GreenDao 在 Android(安卓)Studio 中的配置使用
- 箭头函数的基础使用
- NPM 和webpack 的基础使用
- Python list sort方法的具体使用