-3
我想檢查是否正在使用我的應用程序播放音樂。我已經完成了我的應用程序,它只能使用一次。但我想知道我們如何重複檢查這一點。如何反覆檢查音樂播放器是否處於活動狀態?
這是我的代碼。但是這個代碼只是檢查音樂是否活動或不活動一次。
if(mAudioManager.isMusicActive()) {
Toast.makeText(this, "Audio is playing", Toast.LENGTH_LONG).show();
Intent srvc = new Intent(this, OverlayShowingService.class);
startService(srvc);
try {
Timer timer = new Timer();
timer.wait(1000);
} catch (Exception e) {
System.out.println("Exception found");
}
}
嗨,歡迎來到Stack Overflow。可能是一個想法,用一些關於**你試過的**和**你有什麼問題**的更多信息來格式化你的問題。另外,請不要隨意CAPITALIZE字樣,我們不是聾啞人。 – ScottMcGready
確定@scottmcgready,我已經改變了,正如你所說的。 –