2012-04-22 43 views
0

我用下面這段代碼在廣播接收器獲得音頻管理器Android的音頻管理器在廣播接收機

AudioManager audio = (AudioManager) getSystemService(AUDIO_SERVICE); 

但它顯示錯誤&文摘說AUDIO_SERVICE不能被解析爲一個變量

這裏有什麼問題?它如何解決?

回答

2

嘗試:

AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE); 
+2

它應該是'AudioManager音頻= AudioManager)context.getSystemService(Context.AUDIO_SERVICE);' – 2014-02-03 15:47:12

4

試試這個

public void onReceive(Context context, Intent intent) { 
    AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);