Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

How to add music to andoid project

MediaPlayer mediaPlayer;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.yoursong);

    mediaPlayer.start();

}

@Override
protected void onPause() {
    super.onPause();
    mediaPlayer.stop();
    mediaPlayer.release();

}
Comment

PREVIOUS NEXT
Code Example
Java :: spring boot sql logging 
Java :: ripple effect textview android 
Java :: android studio list of strings 
Java :: java foreach map 
Java :: java int to double 
Java :: display an image java 
Java :: convert int to hex java 
Java :: What is a point class in java? 
Java :: java stream sum integers 
Java :: java get classname 
Java :: how to generate random number in java 
Java :: region in android studio 
Java :: Loop Structure in Java 
Java :: How do I make a splash screen? 
Java :: indexoutofboundsexception java 
Java :: How to do press enter to continue in java 
Java :: intent in fragment android 
Java :: how to get width android 
Java :: change button text onclick javca 
Java :: check instance of java 
Java :: random java 
Java :: convert int[] to list java 
Java :: java divisible by operator 
Java :: string to hexstring In java 
Java :: Problem adding rectangle in javaFX 
Java :: java max int value 
Java :: convert array of int to arraylist java 
Java :: does set automatically get rid of duplicates in java 
Java :: java get all directories in path 
Java :: how to print an array in java 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =