检查网络覆盖Android的尝试发送短信之前 [英] Check Network Coverage in Android before trying to send SMS

查看:251
本文介绍了检查网络覆盖Android的尝试发送短信之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建Android智能手机来检查,如果手机处于飞行模式的应用程序。如果是,应用程序获取手机关闭飞行模式,并检查是否有任何网络连接来发送短信。当我说的网络连接,我的意思是移动电话网络覆盖发送短信,我不想检查互联网连接。如果有网络连接的应用程序将尝试发送短信。

I want to create an application for Android smartphones that checks if the phone is in Airplane Mode. If it is, the application gets the phone off the Airplane mode and checks if there is any network connectivity to send a SMS. When I say network connectivity, I mean mobile phone network coverage to send the SMS, I don't want to check for internet connectivity. If there is network connectivity the application will try to send a SMS.

我已经成功地做​​到了飞行模式检测和切换,但我没有找到一个方法来查看手机是否已连接到蜂窝网络,如果有覆盖。我发现,检查互联网网络连接的例子很多,但不是我所需要的。

I have managed to do the Airplane Mode check and toggle, but I don't find a way to see if the phone is connected to the cellular network and if there is coverage. I found many examples that check for internet network connectivity, but is not what I need.

有没有什么办法来检查电话连接到蜂窝网络,如果有覆盖发送短信?

Is there any way to check if the phone is connected to the cellular network and if there is coverage to send SMS?

在此先感谢您的帮助。

推荐答案

使用此检查信号强度:

    TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

    PhoneStateListener signalListener = new PhoneStateListener() {
        public void onSignalStrengthChanged(int asu) {
            //asu is the signal strength
        }
    };

    telephonyManager.listen(signalListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTH);

这篇关于检查网络覆盖Android的尝试发送短信之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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