1
String videoId = "dD40VXFkusw";
int VIDEO_APP = 5551;
Intent videoClient = new Intent(Intent.ACTION_VIEW);
videoClient.setData(Uri.parse("http://m.youtube.com/watch?v="+videoId));
videoClient.setClassName("com.google.android.youtube","com.google.android.youtube.PlayerActivity");
              startActivityForResult(videoClient, VIDEO_APP);

This used to work for me to show a youtube video in the native player but now I get an ActivityNotFoundException. Why is this?

(06-10 09:23:33.949: ERROR/AndroidRuntime(27869): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.google.android.youtube/com.google.android.youtube.PlayerActivity}; have you declared this activity in your AndroidManifest.xml?
)
Vincent
  • 6,058
  • 15
  • 52
  • 94

2 Answers2

0

Declared "com.google.android.youtube" activity in your project AndroidManifest.xml.

Also install youtube app in your device/emulator.

If youtube app is not available in your device, Then this type of error will be generated.

Ranjitsingh Chandel
  • 1,479
  • 6
  • 19
  • 33
0

You cannot specify a class name for an intent that is outside your APK in the way that you're trying to with Intent.setClassName(). What you need to do instead is simply give the URL and let Android resolve which app is best suited. See Android YouTube app Play Video Intent for more information.

Community
  • 1
  • 1
Mark Allison
  • 21,839
  • 8
  • 47
  • 46