当我点击退出按钮时,我的歌曲并没有停止。
这是代码:
public class Main1Activity extends AppCompatActivity {
MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main1);
mp = MediaPlayer.create(Main1Activity.this,R.raw.b);
Button play = (Button)findViewById(R.id.btn_play);
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mp.start();
}
});
Button stop = (Button)findViewById(R.id.btn_stop);
stop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mp.pause();
}
});
}
}