2013-01-17 144 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」用於啓動器活動,那麼應用程序將無法打開 –

相關問題