Play Youtube videos in your App

  1. Download youtube player API from
  2. Extract the downloaded file and copy “YouTubeAndroidPlayerApi.jar”
  3. Paste “YouTubeAndroidPlayerApi.jar” to your android project “libs” folder
  4. Register your application: open the credential page here
  5. Click on create Project (if you don't have already).
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.FirstProject"
minSdkVersion 16
targetSdkVersion 29
versionCode buildCode
versionName buildName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
private fun startYoutubeActivity(videoId: String) {
val intent = YouTubeStandalonePlayer.createVideoIntent(this, BuildConfig.YOUTUBE_DEVELOPER_KEY, videoId)
if (intent.resolveActivity(this.packageManager) != null) {
} else {
val webIntent = Intent(Intent.ACTION_VIEW, Uri.parse("$videoId"))
if (webIntent.resolveActivity(this.packageManager) != null) {
} else {
// handle the error here

Working remotely as Android Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to get Android Device Current location, i.e

How to add country code picker in Android studio

Pushing the right buttons in Jetpack Compose

Jetpack Compose banner with a laptop, Android logo, mobile phone, and other general shapes.

Integrate the Behavior Awareness feature using Huawei Awareness kit in Android (Kotlin)

PageObject Pattern into App Integration Tests

Differences Between A Normal Class and A Data Class In Kotlin

Navigating in a pure jetpack compose project — part #1

How to preload Room Database with prepackaged DB 🗃

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gaurav Rajput

Gaurav Rajput

Working remotely as Android Developer

More from Medium

I will do instagram marketing or promote for organic growth fast


How to run a website audit?

How to Use Video to Expand your Reach on Social Media

video to expand reach