简体   繁体   English

如何防止其他Android应用访问我的活动

[英]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.

相关问题 Android:如何使用其他应用程序提供的活动? - Android: How do I use activities provided from other apps? 如何防止其他iOS / Android应用程序使用我的RESTful API? - How can I prevent other iOS/Android apps from using my RESTful API? Android如何防止手机从Playstore下载应用程序? - android how do i prevent mobile to download apps from playstore? 当被浏览器要求时,如何阻止Google Play在我的Android设备上安装应用程序? - How can I prevent Google Play from installing apps on my Android device when asked to do so from a browser? 关于Android,如何防止其他应用读取我的联系人 - About Android, how to prevent other apps reading my contacts 如何防止其他应用停止我的应用的后台服务? - How to Prevent other apps from stopping background service of my app? 如何将NavigationDrawer从活动模板添加到其他活动? - How do I add NavigationDrawer from an activity template to other activities? 如果我的应用程序是从最近的应用程序屏幕启动的,如何防止后退按钮退出我的应用程序? - How do I prevent the back button from exiting my app if it was launched from recent apps screen? 如何防止android studio跳过活动? - How to prevent android studio from skipping activities? 如何将其他活动添加到我的android项目? - How to add other activities to my android project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM