Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6147185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:04:05+00:00 2026-05-23T19:04:05+00:00

when i click the button i start a activity for youtube video like this:

  • 0

when i click the button i start a activity for youtube video like this:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=cxLG2wtE7TM")));

if i use this its redirect to the intent chooser to open that video url on browser or youtube app. how to select the default app as youtube programmatically?

my output should open that video directly on youtube player. how? any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:04:06+00:00Added an answer on May 23, 2026 at 7:04 pm

    Asking for a specific Activity is risky, as YouTube may change their package name which will follow with your application breaking.

    Also – there is no guarantee that the YT player is installed on all Android Devices.

    To circumvent, here is a code that searches for a youtube activity. If it finds it, it returns an intent to use it directly, otherwise, it keeps a “generic” intent that will result in the system intent chooser to be displayed.

    /**
     * @param context
     * @param url To display, such as http://www.youtube.com/watch?v=t_c6K1AnxAU
     * @return an Intent to start the YouTube Viewer. If it is not found, will
     *         return a generic video-play intent, and system will display a
     *         chooser to ther user.
     */
    public static Intent getYouTubeIntent(Context context, String url) {
      Intent videoIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
      final PackageManager pm = context.getPackageManager();
      List<ResolveInfo> activityList = pm.queryIntentActivities(videoIntent, 0);
      for (int i = 0; i < activityList.size(); i++) {
        ResolveInfo app = activityList.get(i);
        if (app.activityInfo.name.contains("youtube")) {
          videoIntent.setClassName(app.activityInfo.packageName, app.activityInfo.name);
          return videoIntent;
        }
      }
      return videoIntent;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When click a button,I want to popup a view form bottom,like this! Any help
When I press the button new activity starts. In this activity pop-ups alertdialog with
in the application when user click on button to run new activity it have
So I have a ListView on which I click to start new Activity called
Typical jQuery over-use: $('button').click(function() { alert('Button clicked: ' + $(this).attr('id')); }); Which can be
I want to be able to click a button and open a new form
Is there a way to start an activity from a view? I have this
I am using Button in main Activity. When i clicked this button it will
I am using following code to start activity when user pressing search button on
I have an Activity with a Button which Intent is relative to how the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.