平板电脑能打电话? (电话) [英] Can tablets make calls? (Telephony)

查看:247
本文介绍了平板电脑能打电话? (电话)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在清单的权限:

 <uses-feature 
   android:name="android.permission.READ_PHONE_STATE"  android:required="false" />

在code如果正在使用的电话,检查可能会开始像平板电脑,谁也无法接听电话设备安全异常。所以,我做了这个方法检查是否或不是设备可以使用TelephonyManager:

The code that checks if the telephone is being used would probably start a security exception for devices like tablets, who can't receive calls. So, I made this method to check whether or not the device can use the TelephonyManager:

private boolean doesUserHavePermission(){
    PackageManager pm = getPackageManager();
    final boolean deviceHasPhone = pm.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
    return deviceHasPhone;
}

而在code:如果正在接收一个电话,我实际检查,我把一个if语句,看看设备是否具有或不具有电话:

And in the code where I actually check if a call is being received, I put an if statement to see whether the device has or doesn't have the phone:

private PhoneStateListener phoneStateListener = new PhoneStateListener() {
    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
        if (doesUserHavePermission()) { //I ADDED THIS
            if (state == TelephonyManager.CALL_STATE_RINGING) {
                onPhoneCallInterrupt(); //Method I made that mutes audio for phone call
            } else if (state == TelephonyManager.CALL_STATE_IDLE) {
            } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
                onPhoneCallInterrupt(); //Method I made that mutes audio for phone call
            }
        }
    }
};

我做了一个敬酒检查布尔方法的返回值 doesUserHavePermission(),它的总是返回true,甚至在我的模拟器平板电脑...这是奇怪,因为药片不能拨打/接听电话...

I made a toast to check the return value of that boolean method doesUserHavePermission() and it always returns true, even on my emulator tablet...that's odd because tablets can't make/receive calls...

模拟器设备,我在测试这个是:

The emulator device I was testing this on was:

在这里输入的形象描述

为什么是布尔总是真的,我应该如何恰当地改变我的方法是什么?

推荐答案

挂钩平板电脑到电脑,让平板电脑上的应用程序运行,并检查它是否仍然返回true。
模拟器是不可靠的画这样的结论,因为仿真器的手机上有一个手机应用程序的同时也不能打电话。

Hook up your tablet to your computer and let the application run on your tablet and check if it still returns true. The emulator is not reliable to draw a conclusion like that, since an emulator phone has a phone-application on it too while it can't call.

顺便说一句,尽量提供清晰的照片与你的问题。包含的是一个是不可读的,我不能得到任何信息出来。

By the way, try to provide clear pictures with your question. The one you included is unreadable and I can't get any information out of it.

这篇关于平板电脑能打电话? (电话)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆