我如何$访问我activites p $ pvent其他Android应用 [英] How do I prevent other android apps from accessing my activites

查看:145
本文介绍了我如何$访问我activites p $ pvent其他Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序中,我在清单中定义多个不同的活动。其中一些活动有意向的过滤器,我使用(如ACTION_PICK)。这些活动是因为意向过滤器,显示当其他应用程序请求的活动来处理ACTION_PICK。有没有一些方法,以prevent这一点,所以,我的活动,不能访问其他应用程序?我已经尝试设置的android:在我的活动远销=假,但没有采取任何行动。

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.

推荐答案

您需要:
*定义权限(这仅适用于具有签名的应用程序)
*定义您的应用程序使用您定义的权限
*要求准许你想保护的活动。 (注意不要需要为您的主要推出的活动)。

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>

这篇关于我如何$访问我activites p $ pvent其他Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆