计时器类在Android Pie API 28中不起作用?

时间:2019-06-06 18:51:04

标签: android android-widget

在我使用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);
        }
    }
});

0 个答案:

没有答案