How to add music to andoid project code example
Example: 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();
}