2013-10-16 178 views
0

我試圖使用YouTubeStandalonePlayer從https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeStandalonePlayer無法啓動活動 - YouTubeStandalonePlayer

有了這個代碼裏面onCreate()

Intent intent = YouTubeStandalonePlayer.createVideoIntent(this, DeveloperKey.DEVELOPER_KEY, VIDEO_ID); 
startActivity(intent); 

但應用程序失敗,錯誤。

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.youtubestandalone/com.example.youtubestandalone.MainActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=com.google.android.youtube.api.StandalonePlayerActivity.START (has extras) } 

如何解決這個問題?

+1

你有沒有在Manifest.xml中定義這個活動? –

回答

2

此行添加到您的AndroidManifest.xml

<activity 
      android:name="com.google.android.youtube.api.StandalonePlayerActivity" 
      android:configChanges="keyboardHidden|orientation|screenSize" 
/> 
+0

您應該實際檢查以查看是否可以在手機上使用Youtube,如下所述:http://stackoverflow.com/a/14477843/396005將活動添加到清單中將無濟於事 –

1

檢查是否已在項目中包含的jar文件。確保你已經完成了以下步驟。

  1. 右鍵點擊你的項目
  2. 選擇屬性
  3. 選擇Java Build Path
  4. 轉到訂單和出口標籤
  5. 蜱YouTubeAndroidPlayerApi

祝你好運!