Reputation: 13747
My app uses a WebView. I need to open a native video player any time a user clicks on a video. I see that sometimes in sites, if you click on a video thumb, it opens a dialog asking you how you want to open it (via web or a video player).
What can I do on the server side or my app so an intent like this will be sent after a click on a video?
Thanks!
Upvotes: 2
Views: 4288
Reputation: 50
The question got a little sideways at the end, but I'll respond to the base question.
1.) "I need to open a native video player any time a user clicks on a video"
Verify the link is a video, and fire an intent for ACTION_VIEW, Here's an example:
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.endsWith(".mp4")) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
return true;
}
else
view.loadUrl(url);
return false;
Upvotes: 3