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.
我编写了使用 AlarmManager 的应用程序,它工作得很好但是当用户用电话说话时,音乐正在 alarmManager 中播放,因此对用户不利。
如何在电话忙时禁用 AlarmManager
谢谢...
TelephonyManager.getCallState()告诉你,如果用户现在正在使用手机:
TelephonyManager.getCallState()
private boolean isUserInCall(Context context) { TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE; }