2013-04-08 72 views
1

我TestApp其啓動活動有以下代碼:行動意圖造成ActivityNotFoundException同時開始另一個活動

public void startOperaView() { 
     Intent browserIntent = new Intent("org.droidtv.nettvbrowser.VIEW"); 
     Uri luri = Uri.parse("connectedplanet.tv/olvs/test"); 

     //browserIntent.setClass(getApplicationContext(), Browser.class); 
     //browserIntent.setAction("org.droidtv.nettvbrowser.VIEW"); 
     browserIntent.setType("application/vnd.droidtv.sta"); 
     browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK 
       | Intent.FLAG_INCLUDE_STOPPED_PACKAGES); 
     browserIntent.setData(luri); 

     startActivity(browserIntent); 
    } 

與封裝「org.droidtv.nettvbrowser」具有以下AndroidManifest.xml文件:

<activity 
      android:name="org.droidtv.nettvbrowser.Browser" 
      android:configChanges="locale" 
      android:label="@string/app_name" > 
      <intent-filter> 
      <action android:name="org.droidtv.nettvbrowser.VIEW" /> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
      <category android:name="android.intent.category.DEFAULT" /> 
      <data android:mimeType="application/vnd.droidtv.sta" /> 

      </intent-filter> 
     </activity> 

奇怪的部分是,如果我在意圖中指定實際的軟件包名稱,它似乎工作正常,只有動作意圖是拋出這些errors.Any幫助將不勝感激。謝謝。

回答

0

參考http://developer.android.com/guide/topics/manifest/activity-element.html,你可以嘗試設置android:exported="true"

android:exported 

無論活性可以通過其他應用程序的組件推出 - 「真」如果可以,和「假」如果不是。如果爲「false」,則該活動只能由相同應用程序的組件或具有相同用戶標識的應用程序啓動。 默認值取決於活動是否包含意圖過濾器。沒有任何過濾器意味着該活動只能通過指定其確切的類名稱來調用。這意味着該活動僅用於應用程序內部使用(因爲其他人不知道類名)。所以在這種情況下,默認值是「false」。另一方面,至少存在一個過濾器意味着該活動是爲外部使用的,所以默認值爲「true」。

此屬性不是限制活動暴露於其他應用程序的唯一方法。您還可以使用權限來限制可以調用該活動的外部實體(請參閱權限屬性)。

或者,你可以參考這樣的事情:

<activity android:name="OutgoingCallBroadcaster" 
     android:theme="@android:style/Theme.NoDisplay" 
     android:permission="android.permission.CALL_PHONE" 
     android:configChanges="orientation|screenSize|keyboardHidden"> 
    <!-- CALL action intent filters, for the various ways 
     of initiating an outgoing call. --> 
    <intent-filter> 
     <action android:name="android.intent.action.CALL" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <data android:scheme="tel" /> 
    </intent-filter> 
    <intent-filter android:icon="@drawable/ic_launcher_sip_call"> 
     <action android:name="android.intent.action.CALL" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <data android:scheme="sip" /> 
    </intent-filter> 
    <intent-filter> 
     <action android:name="android.intent.action.CALL" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <data android:scheme="voicemail" /> 
    </intent-filter> 
    <intent-filter> 
     <action android:name="android.intent.action.CALL" /> 
     <category android:name="android.intent.category.DEFAULT" /> 
     <data android:mimeType="vnd.android.cursor.item/phone" /> 
     <data android:mimeType="vnd.android.cursor.item/phone_v2" /> 
     <data android:mimeType="vnd.android.cursor.item/person" /> 
    </intent-filter> 
</activity> 
+0

我用過Android:出口標籤了。沒有運氣。我仍然得到同樣的錯誤。 – harshalizee 2013-04-08 08:55:03

+0

你可以嘗試分離你的兩個意圖行動/類別? – Robin 2013-04-08 09:00:16

+0

你能說說你的意思嗎?我是Android新手。 – harshalizee 2013-04-08 09:12:55

相關問題