Monday, March 2, 2015

Watch Youtube video using intent in android

We can see parcel of android applications playing videos inside the application. Putting videos inside the application will increase the application size and make it heavy. So considering all these things in our mind, we can transfer the video to Youtube and stream it in the application to reduction the application size.



Here is the code for the same:  

Watch youtube video by using youtube Video Id. public static void watchYoutubeVideo(String id, Context con) { try { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + id)); con.startActivity(intent); } catch (ActivityNotFoundException ex) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=" + id)); con.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } } //Use this method to watch youtube video.

0 comments:

Post a Comment

Don't lose faith when you see others receive answers to their prayers

An elephant and a dog became pregnant at same time. Three months down the line the dog gave birth to six puppies. Six months later the dog...

 

G-Expo Template by Ipietoon Cute Blog Design