在我使用Android Pie(API 28)测试我的应用程序之前,我的天文钟表类工作正常。我找不到任何解决方案
chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer chronometer) {
xtime = SystemClock.elapsedRealtime() - chronometer.getBase();
if (xtime >= 1000 && xtime < 2000) {
speechtextlayout.setVisibility(View.VISIBLE);
speechText.setText(getText(R.string.flbdy_easy_5_lipexfoliation_pomegranate_step5_audio1));
releaseMediaPlayer();
int result = mAudiomanager.requestAudioFocus(mAudioFocusChangeListner, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
audio = MediaPlayer.create(ctx, R.raw.fullbody_easy_5_lip_honey_st4_1_washwarm);
audio.start();
audio.setOnCompletionListener(mOncompletion);
}
} else if (xtime > 35000) {
chronometer.stop();
speechtextlayout.setVisibility(View.INVISIBLE);
}
}
});