0

I am working on cab booking app. In all other case I am getting internet status, but I am unable to detect no internet while connected with Bluetooth tethering.

Please any one help me, I'm getting stuck. I need to implement it same like ola and uber app net checking.

I am using below method:

public static boolean isNetworkAvailable(Activity activity) {

    NetworkInfo networkInfo = ((ConnectivityManager) activity
            .getSystemService(Context.CONNECTIVITY_SERVICE))
            .getActiveNetworkInfo();

    Log.d("net", "" + networkInfo);
    // Log.d("net", ""+!networkInfo.isConnected());

    if (networkInfo == null) {
        return false;
    } else {
        if (!networkInfo.isConnected()) {
            return false;
        }
    }

    return true;

}
Sagar Zala
  • 4,854
  • 9
  • 34
  • 62
sunil
  • 796
  • 1
  • 8
  • 28

1 Answers1

0

For check internet status while connected with bluetooth tethering as well as internet connectivity including bluetooth pan . Refer this check Android internet connectivity including bluetooth pan

I will suggest to refer this link . It will help to solve your problem

Community
  • 1
  • 1
Nitin Karande
  • 1,280
  • 14
  • 33
  • Thanx for replay. let me try. – sunil Nov 18 '16 at 13:02
  • try { 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; – sunil Nov 19 '16 at 05:00
  • This method is working fine for me, but please tell me this can i use? and it will not affect. – sunil Nov 19 '16 at 05:01
  • Yes you can. It cant affect. – Nitin Karande Nov 19 '16 at 05:03