Android - 用定制的拨号器屏幕替换内置的拨号器屏幕

发布于 2024-11-23 14:58:58 字数 1406 浏览 2 评论 0原文

我正在为一所学校开发一个“紧急拨号器”,其中会有我不希望用户看到的号码(因为他们是孩子,如果他们看到这些号码,他们可能会对他们造成严重破坏!

)谷歌搜索我发现一篇关于反映“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文