This file contains hidden or 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
object NetworkUtils { | |
fun isConnected(context: Context): Boolean { | |
return isConnected(context, false) | |
} | |
fun isConnected(context: Context, checkNetworkCapability: Boolean): Boolean { | |
var isOnline = false | |
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
val nw = connectivityManager.activeNetwork ?: return false |
This file contains hidden or 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
class EnableLocation : AppCompatActivity() { | |
private fun isLocationEnabled() : Boolean { | |
val locationManager = getSystemService(Context.LOCATION_SERVICE) as LocationManager | |
return locationManager.isLocationEnabled | |
} | |
private fun showEnableLocationDialog() { | |
val locationRequest = LocationRequest.create() | |
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) |