[code]
synchronized void autoAnswerCall(){
Context context = TApplication.nowApplication;
try
{
//插耳机
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
context.sendOrderedBroadcast(localIntent1, "android.permission.CALL_PRIVILEGED");
//按下耳机按钮
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
context.sendOrderedBroadcast(localIntent2, "android.permission.CALL_PRIVILEGED");
//放开耳机按钮
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
context.sendOrderedBroadcast(localIntent3, "android.permission.CALL_PRIVILEGED");
//拔出耳机
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
context.sendOrderedBroadcast(localIntent4, "android.permission.CALL_PRIVILEGED");
}catch (Exception e){
e.printStackTrace();
}
}
[/code]
实现了在模拟机和真机的android2.3系统上的自动接听功能,在模拟机上android4.0系统的也可以,但是在真机android4.0上就不行了(三星19300 4.1系统 和 小米 4.0系统 都不行),
求高手指教如何在真机4.0上实现自动接听功能呀??????(用aidl反射是不行的)
67 个解决方案
#1
你可以使用Telephony manager来接听电话,因此你应该在Broadcast receiver添加以下代码:
if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
{
TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Class c = null;
c = Class.forName(telephony.getClass().getName());
Method m = null;
m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(telephony);
telephonyService.answerRingingCall();
}
#2
@csdn_ask
这个方法不行呀,在4.0上会报权限错误
这个方法不行呀,在4.0上会报权限错误
#3
是啊,普通应用程序没权限接电话的,只有挂电话的权限。否则随便一个应用就能搞到你手机通信功能崩溃了。
#4
帖子不要沉呀,即使实现不了,有权威说法吗, 技术大牛们????等待回复中
#5
无解呀!android 手机就是这么变态 你换个手机 试试 说不定又好了 debug代码仔细看看吧 !只能这样了
#6
这个方法不行呀,在4.0上会报权限错误
#7
你说的是反射那个方法还是我上面代码的方法????你在什么机子上测试的???
#8
帖子不要沉呀,有知道的朋友吗,给个权威的说法????急急急。。。。
#9
我也遇到了这种问题
#10
同求 在部分手机上是可以的 在htc上又不行 擦
#11
你在manifest文件中添加下面的权限了吗?
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_INCOMING_CALLS" />
#12
这些权限都已经加上了
#13
帖子不要沉呀,求助。。。。。
#14
和你寻求同样的问你,帮顶
#15
顶!!求解!遇到同样问题,也是4.0好使,4.1就不行!不知道4.1到底在监听多媒体按键时,咋操作的。
没找到源码。。
希望高手指点!
没找到源码。。
希望高手指点!
#16
也在痛苦中, 求解啊!!
#17
不要考虑了,谷歌开始限制底层危险api了。
#18
那要是root以后呢,可以办到吗?
#19
LZ 有实现这个功能呢 在4.1的机子上,你说的那个方法在4.1上有个权限被弄到系统应用权限了。是不是只有内置到rom下了?
#20
没有呢,一直郁闷中
#21
自动接听电话需要android:sharedUserId="android.uid.system"
并且需要当前系统的签名,如果是想做通用的是不可能的。这一块没有权限。
并且需要当前系统的签名,如果是想做通用的是不可能的。这一块没有权限。
#22
我觉得如果想实现的话,那就弄到底层去啦,自己去开发个系统,自己做API
我是小白,别问我,我什么都不知道
我是小白,别问我,我什么都不知道
#23
问题解决了,谢谢大家的帮助关心
#24
怎么解决的,分享一下撒
#25
做这个功能之前,楼主必须得先报告你这么做的目的是什么。
#26
我在琢磨通过广播记录电话时长,4.0版本有限制,郁闷。
#27
这个需要较高的权限。好像光在Manifest文件中声明是不够的。
必须获取root权限,或者直接把程序安装到系统目录下即可。
必须获取root权限,或者直接把程序安装到系统目录下即可。
#28
各位同胞们,都研究的怎么样啦?我也开始步你们的后尘了,一路的纠结啊,求解。。。。。
#29
这类高危操作,从android4.0开始会逐渐不灵的,4.2更严格
#30
sharedUserId="android.uid.system" + 必须获取root权限
#31
同问哪,进来看看
#32
LZ不厚道啊,问题解决了也不说下咋解决的
#33
真是不厚道啊.楼主
#34
#35
这是不好意思哦,这段时间一直在忙,忙的晕头转向的,忘记贴出来了
代码如下:
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
#36
最近一段时间忙的晕头转向的,忘记吧解决的方法贴出来了,大牛们们给瞧瞧看看,是否可以改进
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
#37
有机会试试,不知道是否还需要系统签名了
#38
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
这一句,我怎么出错啊问题在:TApplication.nowApplication
这一句,我怎么出错啊问题在:TApplication.nowApplication
#39
能不能把你的工程源码发一下啊,我的QQ:286606889
#40
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
这一句,我怎么出错啊问题在:TApplication.nowApplication
这是一个Context对象,你换成其他的就可以了
#41
请问下楼主,你做的挂断电话反射的方法 在小米上也行么 我怎么endCall在小米上不行啊 提示说 call_phone这个权限访问不到
#42
请问下楼主,你做的挂断电话反射的方法 在小米上也行么 我怎么endCall在小米上不行啊 提示说 call_phone这个权限访问不到
#43
请问这个方法是通用的吗?
是不是只用这一个方法就接起了所有电话??
是不是只用这一个方法就接起了所有电话??
最近一段时间忙的晕头转向的,忘记吧解决的方法贴出来了,大牛们们给瞧瞧看看,是否可以改进
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
#44
最近一段时间忙的晕头转向的,忘记吧解决的方法贴出来了,大牛们们给瞧瞧看看,是否可以改进
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
我在三星手机上测试,4.1.2系统,还是接不起电话啊。
#45
最近一段时间忙的晕头转向的,忘记吧解决的方法贴出来了,大牛们们给瞧瞧看看,是否可以改进
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
我在三星手机上测试,4.1.2系统,还是接不起电话啊。
你那是三星什么手机?是三星原来的4.12系统吗?我在note2 4.12上可以
#46
我是三星i9300,刷机成4.12,我又测了一下,好像会被lbe拦截,关掉后就可以了,不过在索尼的4.12上还是不行,有时候还会变成直接挂断电话,那是怎么回事?
#47
我是三星i9300,刷机成4.12,我又测了一下,好像会被lbe拦截,关掉后就可以了,不过在索尼的4.12上还是不行,有时候还会变成直接挂断电话,那是怎么回事?
#48
挂掉是因为前面拦截异常造成的 有很多手机上都会出现偶尔接听会挂断的情况 所以可以直接使用
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
就可以了,前面的不需要。
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
就可以了,前面的不需要。
#49
挂掉是因为前面拦截异常造成的 有很多手机上都会出现偶尔接听会挂断的情况 所以可以直接使用
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
就可以了,前面的不需要。
前面的不需要是指哪里前面不需要?我这也出现了偶尔会挂断的情况
#50
LZ您好 我是android 小白 请问ITelephony itelephony = getITelephony(mTelephonyManager) 中的mTelephonyManager 是什么参数?然后这个函数的功能是手机接到来电的时候不需划屏就可以直接接电话么?(就是电话一来不需要什么操作 直接就通话了)
#1
你可以使用Telephony manager来接听电话,因此你应该在Broadcast receiver添加以下代码:
if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
{
TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
Class c = null;
c = Class.forName(telephony.getClass().getName());
Method m = null;
m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(telephony);
telephonyService.answerRingingCall();
}
#2
@csdn_ask
这个方法不行呀,在4.0上会报权限错误
这个方法不行呀,在4.0上会报权限错误
#3
是啊,普通应用程序没权限接电话的,只有挂电话的权限。否则随便一个应用就能搞到你手机通信功能崩溃了。
#4
帖子不要沉呀,即使实现不了,有权威说法吗, 技术大牛们????等待回复中
#5
无解呀!android 手机就是这么变态 你换个手机 试试 说不定又好了 debug代码仔细看看吧 !只能这样了
#6
这个方法不行呀,在4.0上会报权限错误
#7
这个方法不行呀,在4.0上会报权限错误
你说的是反射那个方法还是我上面代码的方法????你在什么机子上测试的???
#8
帖子不要沉呀,有知道的朋友吗,给个权威的说法????急急急。。。。
#9
我也遇到了这种问题
#10
同求 在部分手机上是可以的 在htc上又不行 擦
#11
@csdn_ask
这个方法不行呀,在4.0上会报权限错误
你在manifest文件中添加下面的权限了吗?
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_INCOMING_CALLS" />
#12
这些权限都已经加上了
引用 2 楼 liubaoxinggo 的回复:
@csdn_ask
这个方法不行呀,在4.0上会报权限错误
你在manifest文件中添加下面的权限了吗?
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.pe……
#13
帖子不要沉呀,求助。。。。。
#14
和你寻求同样的问你,帮顶
#15
顶!!求解!遇到同样问题,也是4.0好使,4.1就不行!不知道4.1到底在监听多媒体按键时,咋操作的。
没找到源码。。
希望高手指点!
没找到源码。。
希望高手指点!
#16
也在痛苦中, 求解啊!!
#17
不要考虑了,谷歌开始限制底层危险api了。
#18
不要考虑了,谷歌开始限制底层危险api了。
#19
LZ 有实现这个功能呢 在4.1的机子上,你说的那个方法在4.1上有个权限被弄到系统应用权限了。是不是只有内置到rom下了?
#20
LZ 有实现这个功能呢 在4.1的机子上,你说的那个方法在4.1上有个权限被弄到系统应用权限了。是不是只有内置到rom下了?
#21
自动接听电话需要android:sharedUserId="android.uid.system"
并且需要当前系统的签名,如果是想做通用的是不可能的。这一块没有权限。
并且需要当前系统的签名,如果是想做通用的是不可能的。这一块没有权限。
#22
我觉得如果想实现的话,那就弄到底层去啦,自己去开发个系统,自己做API
我是小白,别问我,我什么都不知道
我是小白,别问我,我什么都不知道
#23
问题解决了,谢谢大家的帮助关心
#24
问题解决了,谢谢大家的帮助关心
#25
做这个功能之前,楼主必须得先报告你这么做的目的是什么。
#26
我在琢磨通过广播记录电话时长,4.0版本有限制,郁闷。
#27
这个需要较高的权限。好像光在Manifest文件中声明是不够的。
必须获取root权限,或者直接把程序安装到系统目录下即可。
必须获取root权限,或者直接把程序安装到系统目录下即可。
#28
各位同胞们,都研究的怎么样啦?我也开始步你们的后尘了,一路的纠结啊,求解。。。。。
#29
这类高危操作,从android4.0开始会逐渐不灵的,4.2更严格
#30
sharedUserId="android.uid.system" + 必须获取root权限
#31
同问哪,进来看看
#32
问题解决了,谢谢大家的帮助关心
LZ不厚道啊,问题解决了也不说下咋解决的
#33
真是不厚道啊.楼主
#34
#35
问题解决了,谢谢大家的帮助关心
LZ不厚道啊,问题解决了也不说下咋解决的
这是不好意思哦,这段时间一直在忙,忙的晕头转向的,忘记贴出来了
代码如下:
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
#36
最近一段时间忙的晕头转向的,忘记吧解决的方法贴出来了,大牛们们给瞧瞧看看,是否可以改进
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
#37
有机会试试,不知道是否还需要系统签名了
#38
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
这一句,我怎么出错啊问题在:TApplication.nowApplication
这一句,我怎么出错啊问题在:TApplication.nowApplication
#39
能不能把你的工程源码发一下啊,我的QQ:286606889
#40
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
这一句,我怎么出错啊问题在:TApplication.nowApplication
这是一个Context对象,你换成其他的就可以了
#41
请问下楼主,你做的挂断电话反射的方法 在小米上也行么 我怎么endCall在小米上不行啊 提示说 call_phone这个权限访问不到
#42
请问下楼主,你做的挂断电话反射的方法 在小米上也行么 我怎么endCall在小米上不行啊 提示说 call_phone这个权限访问不到
#43
请问这个方法是通用的吗?
是不是只用这一个方法就接起了所有电话??
是不是只用这一个方法就接起了所有电话??
最近一段时间忙的晕头转向的,忘记吧解决的方法贴出来了,大牛们们给瞧瞧看看,是否可以改进
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
#44
最近一段时间忙的晕头转向的,忘记吧解决的方法贴出来了,大牛们们给瞧瞧看看,是否可以改进
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
我在三星手机上测试,4.1.2系统,还是接不起电话啊。
#45
最近一段时间忙的晕头转向的,忘记吧解决的方法贴出来了,大牛们们给瞧瞧看看,是否可以改进
/**
* 该方法可以用于4.1的接听
*/
public void autoAnswerPhone() {
try {
ITelephony itelephony = getITelephony(mTelephonyManager);
//itelephony.silenceRinger();
itelephony.answerRingingCall();
} catch (Exception e) {
e.printStackTrace();
try {
Intent intent = new Intent("android.intent.action.MEDIA_BUTTON");
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
intent = new Intent("android.intent.action.MEDIA_BUTTON");
keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
intent.putExtra("android.intent.extra.KEY_EVENT",keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(intent,"android.permission.CALL_PRIVILEGED");
Intent localIntent1 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent1.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent1.putExtra("state", 1);
localIntent1.putExtra("microphone", 1);
localIntent1.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent1,"android.permission.CALL_PRIVILEGED");
Intent localIntent2 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent1 = new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent2.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent1);
TApplication.nowApplication.sendOrderedBroadcast(localIntent2,"android.permission.CALL_PRIVILEGED");
Intent localIntent3 = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent localKeyEvent2 = new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_HEADSETHOOK);
localIntent3.putExtra("android.intent.extra.KEY_EVENT", localKeyEvent2);
TApplication.nowApplication.sendOrderedBroadcast(localIntent3,"android.permission.CALL_PRIVILEGED");
Intent localIntent4 = new Intent(Intent.ACTION_HEADSET_PLUG);
localIntent4.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
localIntent4.putExtra("state", 0);
localIntent4.putExtra("microphone", 1);
localIntent4.putExtra("name", "Headset");
TApplication.nowApplication.sendOrderedBroadcast(localIntent4,"android.permission.CALL_PRIVILEGED");
} catch (Exception e2) {
e2.printStackTrace();
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
}
}
}
我在三星手机上测试,4.1.2系统,还是接不起电话啊。
你那是三星什么手机?是三星原来的4.12系统吗?我在note2 4.12上可以
#46
我是三星i9300,刷机成4.12,我又测了一下,好像会被lbe拦截,关掉后就可以了,不过在索尼的4.12上还是不行,有时候还会变成直接挂断电话,那是怎么回事?
#47
我是三星i9300,刷机成4.12,我又测了一下,好像会被lbe拦截,关掉后就可以了,不过在索尼的4.12上还是不行,有时候还会变成直接挂断电话,那是怎么回事?
#48
挂掉是因为前面拦截异常造成的 有很多手机上都会出现偶尔接听会挂断的情况 所以可以直接使用
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
就可以了,前面的不需要。
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
就可以了,前面的不需要。
#49
挂掉是因为前面拦截异常造成的 有很多手机上都会出现偶尔接听会挂断的情况 所以可以直接使用
Intent meidaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_HEADSETHOOK);
meidaButtonIntent.putExtra(Intent.EXTRA_KEY_EVENT,keyEvent);
TApplication.nowApplication.sendOrderedBroadcast(meidaButtonIntent, null);
就可以了,前面的不需要。
前面的不需要是指哪里前面不需要?我这也出现了偶尔会挂断的情况
#50
LZ您好 我是android 小白 请问ITelephony itelephony = getITelephony(mTelephonyManager) 中的mTelephonyManager 是什么参数?然后这个函数的功能是手机接到来电的时候不需划屏就可以直接接电话么?(就是电话一来不需要什么操作 直接就通话了)