[英]How do I prevent other android apps from accessing my activities
I have an android app in which I define several different activities in the manifest. 我有一个Android应用程序,其中在清单中定义了几种不同的活动。 Some of these activities have intent-filters that I use (such as ACTION_PICK).
其中一些活动具有我使用的意图过滤器(例如ACTION_PICK)。 These activities, because of the intent-filters, show up when other applications request an activity to handle an ACTION_PICK.
由于其他目的过滤器,这些活动会在其他应用程序请求活动来处理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.
我已经尝试在活动中设置android:exported =“ false”,但这没做。
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.