Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 BroadCast Receiver 中使用下面的代码来获取音频管理器
AudioManager audio = (AudioManager) getSystemService(AUDIO_SERVICE);
但它显示错误 & eclips 说AUDIO_SERVICE 无法解析为变量
这里有什么问题?如何解决?
试试这个
public void onReceive(Context context, Intent intent) { AudioManager audio = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
尝试:
AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);