Answers for "How to make a music app for Android"

1

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();

}
Posted by: Guest on May-27-2021

Code answers related to "How to make a music app for Android"

Browse Popular Code Answers by Language