android studio 1.5.1, marshmallow no internet access detected won't automatically reconnect

前端 未结 5 2043
旧时难觅i
旧时难觅i 2020-12-21 18:30

I\'m having this problem on some 2013 Nexus 7\'s.

got some code to work (please see below).

package acme.wifi;
import android.content.*;
import and         


        
相关标签:
5条回答
  • 2020-12-21 18:48

    I think need to add Network State Access permission in AndroidManifest.xml

        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    
    0 讨论(0)
  • 2020-12-21 18:49

    Add permission in the manifest file:

    1. android.permission.ACCESS_FINE_LOCATION
    2. android.permission.ACCESS_COARSE_LOCATION
    3. Turn on Location Service
    0 讨论(0)
  • 2020-12-21 18:51

    I have same issue with 5.1.1 and Try to ping server of google.com like:

    public Boolean isOnline() {
        try {
    // Process  p1 = runtime.exec("/system/bin/ping -c 1 8.8.8.8");
    
            Process p1 = java.lang.Runtime.getRuntime().exec("ping -c 1 www.google.com");
            int returnVal = p1.waitFor();
            boolean reachable = (returnVal==0);
            return reachable;
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return false;
    }
    

    this will give you correct response.

    0 讨论(0)
  • 2020-12-21 18:53

    The new code in the question seems to work.

    4/16 now the code has stopped working :(

    0 讨论(0)
  • 2020-12-21 19:10

    I was facing the same problem, but I have solved it.

    Add these permissions:

    • android.permission.ACCESS_FINE_LOCATION
    • android.permission.ACCESS_COARSE_LOCATION

    and Keep Location Service ON.

    Strange but true.

    0 讨论(0)
提交回复
热议问题