0

I am trying to use YouTubeStandalonePlayer from https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeStandalonePlayer

With this code inside onCreate():

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

But application fails with error.

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) }

How to fix this?

Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455
nyaa
  • 1,706
  • 2
  • 11
  • 7

2 Answers2

2

Add this line to your AndroidManifest.xml

<activity
            android:name="com.google.android.youtube.api.StandalonePlayerActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
 />
Biraj Zalavadia
  • 28,348
  • 10
  • 61
  • 77
  • You should actually check to see if Youtube is available on the phone as described here: http://stackoverflow.com/a/14477843/396005 Adding the activity to your manifest won't help – Bron Davies Jan 15 '16 at 05:00
1

Check if you have include the jar file in your project. Make sure you have done the follow steps.

  1. Right Click your project
  2. Select Properties
  3. Select Java Build Path
  4. Go to Order and Export Tab
  5. Tick YouTubeAndroidPlayerApi

Good luck!

kinni
  • 11
  • 1