android Activity 保护免受 Intent

标签 android android-intent adb android-permissions data-protection

我正在尝试开发一个带有登录并提供 OTP(一次性密码)连接到 Web 服务的应用程序,但在测试时我能够通过模拟器中的 adb shell 启动 Activity ,即使没有登录,即通过使用完全指定的路径和传递 Intent 。这使得该应用程序很容易被其他应用程序打开而无需登录。是否可以保护 Activity 不通过应用程序外部的 Intent 启动。

下面是一段 list 代码。

    <activity
    android:name=".MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
<activity
    android:name=".LoginActivity"
    android:label="@string/login" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity android:name=".The1Activity" >
</activity>
<activity android:name=".The2Activity" >
</activity>

最佳答案

您的一天节省时间是 -

android:exported = "false"

Documentation says -

Whether or not the activity can be launched by components of other applications — "true" if it can be, and "false" if not. If "false", the activity can be launched only by components of the same application or applications with the same user ID.

关于android Activity 保护免受 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26879431/

相关文章:

android - Android 上的 OpenGL - 纹理映射 - 只有左上角像素可见

android - 无法在 AsyncTask 中访问 "findViewById"

安卓异步任务 : start new Activity in onPostExecute()

java - 无法解析 onActivityResult 方法

android - 从 Eclipse 调试时的 ADB 命令行选项?

android - 在从服务开始 Activity 之前关闭所有 Activity

android - 设置折叠工具栏中 TextView 和 ImageView 的对比度颜色

android - Intent.setType() 返回Android中所有类型的文件

android - ADB Bluestacks - 连接 2 台 PC

android - 如何使用 ADB 命令检测正在运行的应用程序