2013-01-17 147 views
-2

我开始知道,我们可以从android中的其他应用程序中打开一个应用程序。所以我使用android:exported="false"为了限制。但是当我为Launcher添加相同的标签时,则无法打开该应用程序。如何停止从android中的其他应用程序打开应用程序?

<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个意图过滤器)

回答

2

安卓出口

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-filteractivity满足您的intent-filter可以打开你的activity


要完全限制你的活动被其他应用程序

Don't include any intent-filter

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

+1

我注意到使用,对于发射活动我们不能把android:exported =“false”.for我们可以放置的其余活动。如果我们将android:exported =“false”用于启动器活动,那么应用程序将无法打开 –

相关问题