【问题标题】:WiFi connection is up but doesn't work: code or android bug?WiFi 连接已启动但无法正常工作:代码还是 android 错误?
【发布时间】:2011-12-01 21:28:14
【问题描述】:

我编写了一个应用程序,它使用警报管理器每分钟执行一项服务(它持有一个唤醒锁来执行整个执行)以将数据上传到网络上,并且它可以完美运行....有时。

事实上,使用 Logcat(在手机上)我发现有时 WiFi 连接不起作用。状态栏上的图标没问题,我已经为 wifi 待机设置了“从不”。

有时应用程序运行正常超过 20 小时,有时仅 40 分钟,然后 wifi 似乎关闭(但仍有图标和配置设置)。

进行最后一次测试,我试图打开浏览器,但它也不起作用!重新启动上传我需要禁用和启用wifi...所以我认为问题出在android。

我的设备是搭载 Android 2.2 的三星 Galaxy ACE

【问题讨论】:

    标签: android android-wifi


    【解决方案1】:

    目前,这个问题太宽泛,无法回答。也许您可以发布您提到的代码?

    另外,为了进一步调试,

    • 您是否尝试过不同的 wifi 网络?
    • 如果您从不启动应用程序,Wi-Fi 是否正常工作?

    更新:

    听起来这可能是您网络上的 DNS 问题。当 wi-fi 处于“关闭”状态时,您能否检查 DNS 解析是否适用于同一网络中的其他设备(使用相同的 DNS 服务器)?

    【讨论】:

    • 谢谢!由于太长,我无法发布代码。需要了解的内容写在问题中(AlarmManager、WakeLock 和 Service)。
    • 我认为问题出在android内部!不,我不能尝试不同的网络,我不知道第二个答案......
    【解决方案2】:

    我已经解决了只在操作之间禁用和启用连接。

    //disable connection
    android.provider.Settings.System.putInt(getContentResolver(),android.provider.Settings.System.AIRPLANE_MODE_ON,1);
    // Post an intent to reload
    Intent intent1 = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    intent1.putExtra("state", 1);
    sendBroadcast(intent1);
    //connection disabled
    
    
    //enable connection
    android.provider.Settings.System.putInt(getContentResolver(),android.provider.Settings.System.AIRPLANE_MODE_ON,0);
    // Post an intent to reload
    Intent intent4 = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
    intent4.putExtra("state", 0);
    sendBroadcast(intent4);
    //Connection enabled
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-30
      • 2011-06-16
      • 2013-05-21
      • 1970-01-01
      • 2018-12-28
      • 2011-08-12
      相关资源
      最近更新 更多