你如何编程结束2.3+打个电话?打个电话、结束

2023-09-04 22:58:35 作者:无伴终老

最多至Android 2.2,我知道我可以使用反射和终止通过getITelephony呼叫。

Up to Android 2.2 I know I can use reflection and terminate the call through getITelephony.

不过,由于2.3这不再有效,因为即使你授予MODIFY_PHONE_STATE允许你的应用程序,它现在是一个系统的应用程序只有许可: http://stackoverflow.com/a/5095956/821423

However, as of 2.3 this no longer works because even if you grant the MODIFY_PHONE_STATE permission to your app, it's now a system app only permission: http://stackoverflow.com/a/5095956/821423

这就是说,它可能还是因为谷歌播放市场上无数的应用都在做,它只是罚款ICS,比如这一个:

That said, it's possible still because a myriad of applications on the google play market are doing it just fine on ICS, for example, this one:

https://play.google.com/store/apps/details?id=com.androminigsm.fscifree&hl=en

所以,问题是,他们怎么办呢?我知道我可以拿起使用模拟耳机挂钩的电话,但我不知道如何结束通话。

So the question is, how do they do it? I know I can pick up the call using simulating a headset hook, but I can't figure out how to end the call.

感谢你。

推荐答案

自我反省后,嗯,我知道的东西真的,真的,真的很愚蠢。从好的方面无人计算器似乎要么注意到了这一点。 MODIFY_PHONE_STATE不再工作silenceRinger(),因为2.3+,但按结束就好了。

Well after much soul-searching I realize something really, really, really dumb. On the plus side no one on StackOverflow seems to have noticed it either. MODIFY_PHONE_STATE is no longer working on silenceRinger() since 2.3+, but endCall is just fine.

所以,解决的办法是注释掉调用silenceRinger()。

So the solution is to comment out the call to silenceRinger().

无法相信我已经一个星期刚刚度过这个!我会尝试更新的其他问题,因为似乎吨欺骗对SO线沿线的这是不可能的使用反射来了终止呼叫。

Can't believe I've just spent a week on this! I'll try to update the other questions as there seem to be tons of dupe on SO along the lines of 'it's not possible to use reflection to terminate the calls anymore'.