Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void checkNetworkConnection() {
- ConnectivityManager connMgr =
- (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo activeInfo = connMgr.getActiveNetworkInfo();
- if (activeInfo != null && activeInfo.isConnected()) {
- boolean wifiConnected = activeInfo.getType() == ConnectivityManager.TYPE_WIFI;
- boolean mobileConnected = activeInfo.getType() == ConnectivityManager.TYPE_MOBILE;
- if(wifiConnected) {
- Log.i(TAG, "WIFI connected");
- stsRede.setText("Conectado no WiFi");
- } else if (mobileConnected){
- Log.i(TAG, "Mobile Connected");
- //stsRede.setText("Conectado no 3G");
- }
- } else {
- Log.i(TAG,"Neither Mobile nor WIFi connected.");
- //stsRede.setText("Sem conexão a internet");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement