Fix. Fixed onProviderEnabled and onProviderDisabled for LocationListener

Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
This commit is contained in:
HeCodes2Much
2024-07-09 13:42:33 +01:00
parent 6a01b4746f
commit 60374fe6b1
2 changed files with 20 additions and 3 deletions

View File

@@ -167,7 +167,7 @@ fun Context.resetDefaultLauncher() {
}
}
private fun Context.runningStockAndroid() {
fun Context.runningStockAndroid() {
try {
val packageManager = this.packageManager
val componentName = ComponentName(this, FakeHomeActivity::class.java)
@@ -192,7 +192,7 @@ private fun Context.runningStockAndroid() {
}
}
private fun Context.notRunningStockAndroid() {
fun Context.notRunningStockAndroid() {
try {
val intent = Intent("android.settings.HOME_SETTINGS")
this.startActivity(intent)
@@ -468,7 +468,7 @@ fun Context.restoreSharedPreferences(backupFileNames: Array<String>) {
}
}
private fun Context.saveToSharedPreferences(prefsFileName: String, key: String, value: Any) {
fun Context.saveToSharedPreferences(prefsFileName: String, key: String, value: Any) {
val sharedPreferences: SharedPreferences = this.getSharedPreferences(prefsFileName, Context.MODE_PRIVATE)
val editor = sharedPreferences.edit()

View File

@@ -30,6 +30,7 @@ import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.navigateUp
import com.github.droidworksstudio.common.hasInternetPermission
import com.github.droidworksstudio.common.isTablet
import com.github.droidworksstudio.common.showLongToast
import com.github.droidworksstudio.launcher.R
import com.github.droidworksstudio.launcher.databinding.ActivityMainBinding
import com.github.droidworksstudio.launcher.helper.AppHelper
@@ -238,6 +239,22 @@ class MainActivity : AppCompatActivity(), LocationListener {
lastKnownLocation = location
}
override fun onProviderEnabled(provider: String) {
// Handle provider enabled
when (provider) {
LocationManager.GPS_PROVIDER -> applicationContext.showLongToast("GPS Provider Enabled")
LocationManager.NETWORK_PROVIDER -> applicationContext.showLongToast("Network Provider Enabled")
}
}
override fun onProviderDisabled(provider: String) {
// Handle provider disabled
when (provider) {
LocationManager.GPS_PROVIDER -> applicationContext.showLongToast("GPS Provider Disabled")
LocationManager.NETWORK_PROVIDER -> applicationContext.showLongToast("Network Provider Disabled")
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
return true