80,351
社区成员
发帖
与我相关
我的任务
分享
/**广播接收者*/
public void onReceive(Context context, Intent intent) {
System.out.println("onReceive");
try {
if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
handleMessage(context, intent);
} else if("android.intent.action.PHONE_STATE".equals(intent.getAction())){
handleCallPhone(context, intent);
}
} catch (Exception e) {
System.out.println("Exception-->"+e.getMessage());
}
}
自动挂断代码片段:
private void callEnd() throws Exception{
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
// 挂断电话
mITelephony.endCall();
// 再恢复正常铃声
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
}
自动拨打电话手头代码找不到了。不过百度谷歌等一搜就能搜出来吧。