Force video to open in Youtube app on Android
Here's how you can do that:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + id));
startActivity(intent);
The id is the identifier after the questionmark in the url. For example: youtube.com/watch?v=ID
Another way is:
Intent videoIntent = new Intent(Intent.ACTION_VIEW);
videoIntent.setData(url);
videoIntent.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");
startActivity(videoIntent);
......
“href” value in HTML to open video in youtube app or market (Google Play) on Android
1) Intent solution :
<a href="
intent:
//8xn9iq3lG_w/
#Intent;
scheme=vnd.youtube;
package=com.google.android.youtube
S.browser_fallback_url=market://details?id=com.google.android.youtube;
end;
">youtube or market</a>
NB:
Maybe you need to remove spaces in href attribut:
<a href="intent://8xn9iq3lG_w/#Intent;scheme=vnd.youtube;package=com.google.android.youtube;S.browser_fallback_url=market://details?id=com.google.android.youtube;end;">youtube or market</a>
2) Link solution :
You get more information in Settings > Apps > Youtube > Open by default > Supported links:
- youtube.be
- m.youtube.com
- youtube.com
- www.youtube.com
See: https://youtu.be/8xn9iq3lG_w and try, here: http://output.jsbin.com/tubozokebe/
<a target="_blank" href="https://youtu.be/8xn9iq3lG_w">link: https://youtu.be/8xn9iq3lG_w</a> or
<a target="_blank" href="vnd.youtube:8xn9iq3lG_w">link: vnd.youtube:8xn9iq3lG_w</a>
Android - Open links in YouTube app by default
You should create a custom WebViewClient and override shouldOverrideUrlLoading.
This function is being called before the webview goes into the address. There, you should check if the link is a youtube link and if so, open an intent as user6363583 said, and return true, else return false.
Dont forget to set your custom Web client as your webview Web client... Just use: webview.setWebViewClient(yourClient)
How to force a video to play in fullscreen in youtube player?
Youtube v4.1.47 app cando it for you
intent.putExtra("force_fullscreen",true);
I dont know about lower versions.
Android: How to force WebView to play a video from youtube?
i find the answer
mWebview = (WebView) findViewById(R.id.mwebview);
mWebview.setInitialScale(1);
mWebview.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebview.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});
WebSettings webSettings = mWebview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setAllowContentAccess(true);
webSettings.setEnableSmoothTransition(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setSupportZoom(false);
webSettings.setUseWideViewPort(true);
webSettings.setAppCacheEnabled(true);
webSettings.setSupportMultipleWindows(true);
mWebview.loadUrl("http://www.youtube.com/embed/" + video.youtube_id);
Related Topics
How to Hide Action Bar for Fragment
How to Disable Recyclerview Items from Clicking
How to Disable Spinner in Android and Enable It on Button Click
Recyclerview Indicates That Reaches the Last Item
How to Know Which Fragment the User Is Viewing
Android: How to Scale a Bitmap to Fit the Screen Size Using Canvas/Draw Bitmap
Retrofit 2.0 - How to Get Response Body for 400 Bad Request Error
How to Enable Location Access Programmatically in Android
React-Native: Images Not Showing in Android Device; But Shows in Emulator
How to Show a Video Thumbnail from a Video Path
Resolving Problems With Android Studio Freezing Constantly
How to Completely Disable Selinux in Android L in the Init.Rc File
How to Delete Shared Preferences Data from App in Android
How to Keep a Bottom Nav Bar from Being Pushed Up on Keyboard Shown
How to Save an Activity State Using the Save Instance State
How to Close the Current Fragment by Using Button Like the Back Button