-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed error that tried to synchronize even without an internet connection and did not close the Dialog after an error message. - Fixed error that when exiting the app after a synchronization request caused a crash in the app.
- Loading branch information
1 parent
f5ac4da
commit eb8d2b7
Showing
6 changed files
with
105 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
app/src/main/java/br/edu/uepb/nutes/ocariot/utils/ConnectionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package br.edu.uepb.nutes.ocariot.utils; | ||
|
||
import android.bluetooth.BluetoothAdapter; | ||
import android.content.Context; | ||
import android.net.ConnectivityManager; | ||
import android.net.NetworkInfo; | ||
|
||
/** | ||
* Provides routines for checking connection with internet and bluetooth. | ||
* | ||
* @author Douglas Rafael <[email protected]> | ||
* @version 0.1 | ||
* @copyright Copyright (c) 2017, NUTES/UEPB | ||
*/ | ||
public class ConnectionUtils { | ||
/** | ||
* Checks if the device supports bluetooth. | ||
* | ||
* @return true for device supports bluetooth or false otherwise. | ||
*/ | ||
public static boolean isSupportedBluetooth() { | ||
return BluetoothAdapter.getDefaultAdapter() != null; | ||
} | ||
|
||
/** | ||
* Checks if bluetooth is enabled. | ||
* | ||
* @return true to enabled or false otherwise. | ||
*/ | ||
public static boolean bluetoothIsEnabled() { | ||
return BluetoothAdapter.getDefaultAdapter() != null && | ||
BluetoothAdapter.getDefaultAdapter().isEnabled(); | ||
} | ||
|
||
/** | ||
* Checks if the device has an internet connection. | ||
* | ||
* @param context | ||
* @return boolean | ||
*/ | ||
public static boolean isNetworkAvailable(Context context) { | ||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | ||
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); | ||
return (networkInfo != null && networkInfo.isConnectedOrConnecting()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters