能否telephony.Phone对象通过SDK进行实例化? [英] Can a telephony.Phone object be instantiated through the sdk?
问题描述
我想获得一个电话对象,这样我可以打电话,从我的应用研讨会两个数字。
I am trying to get a phone object so that I can call and conference two numbers from within my application.
我已经使用静态PhoneFactory.makeDefaultPhones((上下文)本)尝试,但还没有任何运气。
I have tried using the static PhoneFactory.makeDefaultPhones((Context)this) but have not had any luck.
String phoneFactoryName = "com.android.internal.telephony.PhoneFactory";
String phoneName = "com.android.internal.telephony.Phone";
Class phoneFactoryClass = Class.forName(phoneFactoryName);
Class phoneClass = Class.forName(phoneName);
Method getDefaultPhone = phoneFactoryClass.getMethod("getDefaultPhone");
Object phoneObject = getDefaultPhone.invoke(null);
错误 - 通过了java.lang.RuntimeException引起:PhoneFactory.getDefaultPhone必须从弯针线被称为
Error - Caused by java.lang.RuntimeException: PhoneFactory.getDefaultPhone must be called from Looper thread
推荐答案
是的,它可以被实例化。但你必须克服几个障碍:
Yes it can be instantiated. But you have to overcome a couple of hurdles:
-
在你的AndroidManifest.xml中设置
In your AndroidManifest.xml set
安卓sharedUserId =android.uid.phone
android:sharedUserId="android.uid.phone"
清单-标签内。该时间是从保护意图是由你可以调用(如android.intent.action.SIM_STATE_CHANGED)的方式发送被抛出需要prevent一个SecurityException。
within the manifest-Tag. This is required to prevent a SecurityException from being thrown when protected Intents are sent by the methods you may invoke (like android.intent.action.SIM_STATE_CHANGED).
设置
安卓程序=com.android.phone
android:process="com.android.phone"
在您的应用程序标签。这是为了让getDefaultPhone / makeDefaultPhone的调用。
in your application-Tag. This is required to allow the invocation of getDefaultPhone / makeDefaultPhone.
要做到这一切,您的应用程序必须与系统签名密钥进行签名。
To do all this your app must be signed with the system signature key.
这篇关于能否telephony.Phone对象通过SDK进行实例化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!