Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions lib/system_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class SystemSettings {
return await _channel.invokeMethod('app');
}

static Future<void> hotsPot() async {
return await _channel.invokeMethod('hotspot');
}

static Future<void> appNotifications() async {
return await _channel.invokeMethod('app-notifications');
}
Expand Down