Donate Bihar Flood Rescue

A

Android app code for youtube channel

Click Hire Me For Making Android App to go to Create Android App
Youtube Channel App


MAINACTIVITY.XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:id ="@+id/play"
 tools:context="com.example.prosen.youtubeplayer.MainActivity">

<TextView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Hello World!"
 android:id="@+id/textView" />

<Button
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="Play"
 android:id="@+id/button1"
 android:layout_centerVertical="true"
 android:layout_centerHorizontal="true" />

<com.google.android.youtube.player.YouTubePlayerView
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:id="@+id/view1"
 android:layout_alignParentRight="true"
 android:layout_alignParentEnd="true"
 android:layout_above="@+id/button1"
 android:layout_alignParentLeft="true"
 android:layout_alignParentStart="true"
 android:layout_alignParentTop="true" />

</RelativeLayout> 

MAINACTIVITY.JAVA

 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.view.View;
 import android.widget.Button;

 import com.google.android.youtube.player.YouTubeBaseActivity;
 import com.google.android.youtube.player.YouTubeInitializationResult;
 import com.google.android.youtube.player.YouTubePlayer;
 import com.google.android.youtube.player.YouTubePlayerView;

 public class MainActivity extends YouTubeBaseActivity{

 Button button;
 private YouTubePlayerView view;
 private YouTubePlayer.OnInitializedListener listener;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);

 view = (YouTubePlayerView)findViewById(R.id.view1)

 listener = new YouTubePlayer.OnInitializedListener() {
 @Override
 public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer  youTubePlayer, boolean b) {

 youTubePlayer.loadVideo("BvpqMiVNQ7s");

  }

 @Override
 public void onInitializationFailure(YouTubePlayer.Provider provider,  YouTubeInitializationResult youTubeInitializationResult) {
 button =(Button)findViewById(R.id.button1);
 button.setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View v) {
 view.initialize("AIzaSyAi_AF4xeTeo8Q_S0-3j0PFZWWLsycfzMs",listener);
 }
 });
 }
 };
 }

}





MANIFEST.XML

<uses-permission android:name="android.permission.INTERNET"/>

ONLY INPUT THE PERMISSION