按下后,MainActivity不会更新歌曲

时间:2018-05-14 07:21:17

标签: android

当我的音乐应用程序完成歌曲1或您按下next / prev按钮在DetailActivity中播放歌曲2时,我按回,歌曲2继续播放但歌曲2名称不更新。当我按下该歌曲2(歌曲名称为1)时,它会返回并播放歌曲1,然后按下它以转到DetailActivity。谁知道为什么?

编辑:111是MY_REQUEST_CODE,000是MY_RESULT_CODE

MainActivity:

 private void clickMoveSong() {
    mLinearMoveSong.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mServiceMusic.mediaPlayer.isPlaying()) {
                mServiceMusic.mediaPlayer.pause();
            }

            int time = mServiceMusic.mediaPlayer.getCurrentPosition();
            bundle.putInt("thoigian", time);

            Intent imovesong = new Intent(MainActivity.this, DetailSongRuningActivity.class);
            imovesong.putExtra("dulieu", bundle);

            startActivityForResult(imovesong, 111);
        }
    });

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == MY_REQUEST_CODE && resultCode == MY_RESULT_CODE && data != null) {
        int time = data.getExtras().getInt("time");
        ServiceMusic.mediaPlayer.seekTo(time);
        ServiceMusic.mediaPlayer.start();
    }
    super.onActivityResult(requestCode, resultCode, data);
}

DetailSongRunningActivity:

@Override
public void onBackPressed() {
    Intent i = new Intent(DetailSongRuningActivity.this, MainActivity.class);
    i.putExtra("time",TIME_START);
    setResult(000, i);
    if (mserviceMusic.mediaPlayer.isPlaying()) mserviceMusic.mediaPlayer.pause();
    finish();
    super.onBackPressed();
}

0 个答案:

没有答案