0

我开始知道,我们可以从 android 中的其他应用程序中打开一个应用程序。所以我使用android:exported="false"它是为了限制它。但是当我为 Launcher 放置相同的标签时,我无法打开应用程序。

<activity
    android:name="SplashScreen"
    android:label="@string/app_name"
    android:screenOrientation="portrait">
     <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="*/*" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter> 
</activity>

(因为我的应用程序应该能够打开任何文件,所以我应用了 2 个意图过滤器)

4

1 回答 1

5

安卓:导出

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.

The default value depends on whether the activity contains intent filters. The absence of any filters means that the activity can be invoked only by specifying its exact class name. This implies that the activity is intended only for application-internal use (since others would not know the class name).

So in this case, the default value is "false". On the other hand, the presence of at least one filter implies that the activity is intended for external use, so the default value is "true". This attribute is not the only way to limit an activity's exposure to other applications. You can also use a permission to limit the external entities that can invoke the activity (see the permission attribute).


当你使用intent-filter任何activity满足你的东西时,你intent-filter可以打开你的activity.


完全限制您的活动以供其他应用程序使用

1.Don't include any intent-filter

2.Add android:exported="false" inside your <activity> tag

于 2013-01-17T15:06:32.210 回答