-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConnectionDetector.java
More file actions
32 lines (27 loc) · 906 Bytes
/
ConnectionDetector.java
File metadata and controls
32 lines (27 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.puddlesmanagment;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
* Created by dell on 05/07/2018.
*/
public class ConnectionDetector {
private Context _context;
public ConnectionDetector(Context context){
this._context = context;
}
public boolean isConnectingToInternet(){
ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null)
{
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info != null)
//for (int i = 0; i < info.length; i++)
if (info.getState() == NetworkInfo.State.CONNECTED)
{
return true;
}
}
return false;
}
}