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

前端 未结 5 2076
旧时难觅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: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.

提交回复
热议问题