一、背景
如果其他app想跳转到我们的app中,需要将组件暴露给其他app,那么如何将app暴露给其他app将是需要解决的问题。
二、解决方案
在组件注册的地方加上android:exported=“true”
例如:
//另一个app中要启动的service的清单文件中注册信息
<service android:name="com.ang.chapter_2.poolBinder.BinderPoolService"
android:exported="true">
<intent-filter>
<action android:name="com.ang.poolBinder" />
</intent-filter>
</service>
此app中的启动代码
Intent intent = new Intent();
intent.setPackage("com.ang.chapter_2_service");
intent.setAction("com.ang.poolBinder");
startService(intent) //或者bindService(intent, mConnection, Context.BIND_AUTO_CREATE);