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
| fun checkLocationSettings(onSuccessCallback: () -> Unit) { | |
| val locationRequest = LocationRequest.create() | |
| locationRequest.priority = LocationRequest.PRIORITY_LOW_POWER | |
| val builder = LocationSettingsRequest.Builder() | |
| builder.addLocationRequest(locationRequest) | |
| val client = LocationServices.getSettingsClient(this) | |
| val task = client.checkLocationSettings(builder.build()) | |
| task.addOnSuccessListener(this) { | |
| onSuccessCallback() | |
| } |
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
| val network: Network? = connectivityManager.allNetworks.find { | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
| connectivityManager.getNetworkCapabilities(it) | |
| .hasTransport(NetworkCapabilities.TRANSPORT_WIFI) | |
| } else { | |
| connectivityManager.getNetworkInfo(it).extraInfo == wifiSSID | |
| } | |
| } |
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
| val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
| connectivityManager.bindProcessToNetwork(network) | |
| } else { | |
| ConnectivityManager.setProcessDefaultNetwork(network) | |
| } |
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
| val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
| connectivityManager.bindProcessToNetwork(null) | |
| } else { | |
| ConnectivityManager.setProcessDefaultNetwork(null) | |
| } |
OlderNewer