I have an android app in which I define several different activities in the manifest. Some of these activities have intent-filters that I use (such as ACTION_PICK). These activities, because of the intent-filters, show up when other applications request an activity to handle an ACTION_PICK. Is there some way to prevent this, so that my activities are not accessible to other applications? I've already tried setting android:exported="false" in my activity, but that did nothing.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You need to:
* define a permission (which is only available to applications having your signature)
* define that your application uses your defined permission
* require that permission for the activities you want protected. (Be careful to not require it for your main launch activity).
<!-- define a permission -->
<permission
android:protectionLevel="signature"
android:name="com.mypackage.MYPERMISSION"/>
<uses-permission android:name="com.mypackage.MYPERMISSION" />
<!-- define an activity which can only be started through internal code -->
<activity android:name="..."
android:permission="com.mypackage.MYPERMISSION" >
...
</activity>