【问题标题】:Can I force android to recheck connection if it's lost?如果连接丢失,我可以强制 android 重新检查连接吗?
【发布时间】:2021-12-30 21:32:17
【问题描述】:

我可以从我的应用程序中强制 android 立即重新连接到蜂窝网络吗? 如果是的话怎么做?

【问题讨论】:

    标签: android


    【解决方案1】:

    显然Android 5 的功能已仅移至系统应用程序。 How to enable mobile data on/off programmatically

    但您仍然可以为网络更改注册一个监听器。 https://developer.android.com/training/basics/network-ops/reading-network-state

    当您收到onLost() 事件时,您可以启动Wireless Setting Activity,以便用户手动执行此操作。

            //As seen in the link above.
            Intent intent = new Intent(Settings.ACTION_WIRELESS_SETTINGS);
            startActivity(intent);
    

    这将是一个常见的情况,所以要习惯它。例如,您可以将createBond() 用于Bluetooth 设备,但您不能再使用removeBond()。因此,您必须将用户发送到Bluetooth 设置活动,以便用户 “忘记”设备。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-23
      • 2017-12-06
      • 1970-01-01
      • 2020-09-21
      • 1970-01-01
      • 2022-08-11
      • 2014-06-24
      相关资源
      最近更新 更多