Android - 用定制的拨号器屏幕替换内置的拨号器屏幕
我正在为一所学校开发一个“紧急拨号器”,其中会有我不希望用户看到的号码(因为他们是孩子,如果他们看到这些号码,他们可能会对他们造成严重破坏!
)谷歌搜索我发现一篇关于反映“com.android.internal.telephony.ITelephony”类的文章,这似乎让我更接近处理呼叫,但“call(String Phonenumber)”方法会显示已安装的拨号器屏幕显示号码!如何创建自己的不显示号码?
编辑:这是我的拨号方法的代码片段 -
private void performDial(String numberString){
if (!numberString.equals("")) {
TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
try {
// Java reflection to gain access to TelephonyManager's
// ITelephony getter
Log.v(TAG, "Get getTeleService...");
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
com.android.internal.telephony.ITelephony telephonyService =(ITelephony) m.invoke(tm);
//
telephonyService.dial(numberString);//only opens dial screen, does not place call
telephonyService.call(numberString);//places call, but opens built in dial screen which shows dialled number
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG,
"FATAL ERROR: could not connect to telephony subsystem");
Log.e(TAG, "Exception object: " + e);
}
}
else
{
errorOut("Empty number field");
}
}
I'm working on an 'Emergency Dialler' for a school which will have numbers that I don't want the user to see (as they are kids and if they see the numbers they are likely to play havoc with them!)
After much googling I found an article on reflecting the "com.android.internal.telephony.ITelephony" class, which seems to have brought me closer to dealing with calls, but the "call(String phonenumber)" method brings up the installed dialler screen which displays the number! How can I create my own that does not display the number?
edit: here is a code snippet of my dial method -
private void performDial(String numberString){
if (!numberString.equals("")) {
TelephonyManager tm = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
try {
// Java reflection to gain access to TelephonyManager's
// ITelephony getter
Log.v(TAG, "Get getTeleService...");
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
com.android.internal.telephony.ITelephony telephonyService =(ITelephony) m.invoke(tm);
//
telephonyService.dial(numberString);//only opens dial screen, does not place call
telephonyService.call(numberString);//places call, but opens built in dial screen which shows dialled number
} catch (Exception e) {
e.printStackTrace();
Log.e(TAG,
"FATAL ERROR: could not connect to telephony subsystem");
Log.e(TAG, "Exception object: " + e);
}
}
else
{
errorOut("Empty number field");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论