diff --git a/android/src/main/kotlin/de/florianweinaug/system_settings/SystemSettingsPlugin.kt b/android/src/main/kotlin/de/florianweinaug/system_settings/SystemSettingsPlugin.kt index b134a55..2450c9a 100644 --- a/android/src/main/kotlin/de/florianweinaug/system_settings/SystemSettingsPlugin.kt +++ b/android/src/main/kotlin/de/florianweinaug/system_settings/SystemSettingsPlugin.kt @@ -24,6 +24,7 @@ public class SystemSettingsPlugin(private val registrar: Registrar): MethodCallH override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { when (call.method) { "app" -> openAppSettings() + "hotspot" -> openHotsPot() "app-notifications" -> openAppNotificationSettings() "system" -> openSystemSettings() "location" -> openSetting(Settings.ACTION_LOCATION_SOURCE_SETTINGS) @@ -58,6 +59,14 @@ public class SystemSettingsPlugin(private val registrar: Registrar): MethodCallH registrar.context().startActivity(intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) } + private fun openHotsPot(){ + try { + registrar.context().startActivity(Intent().apply{setClassName("com.android.settings", "com.android.settings.TetherSettings")}.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) + } catch (e: Exception) { + openSystemSettings() + } + } + private fun openAppNotificationSettings() { val intent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS) diff --git a/lib/system_settings.dart b/lib/system_settings.dart index 4ceab90..1ad69b9 100644 --- a/lib/system_settings.dart +++ b/lib/system_settings.dart @@ -9,6 +9,10 @@ class SystemSettings { return await _channel.invokeMethod('app'); } + static Future hotsPot() async { + return await _channel.invokeMethod('hotspot'); + } + static Future appNotifications() async { return await _channel.invokeMethod('app-notifications'); }