To open the notification settings from an intent, we can use the action Settings.ACTION_APP_NOTIFICATION_SETTINGS
There are a lot of different actions available to open specific settings screens but I didn't find one to open the new per-app language settings screen.
Am I missing it?
I tried differents strings like "android.settings.APP_LANGUAGES_SETTINGS"
but none worked.
You can use the ACTION_APP_LOCALE_SETTINGS
intent.
It takes in a Uri
to specify the app.
Here's how to use is:
val intent = Intent(Settings.ACTION_APP_LOCALE_SETTINGS)
val uri = Uri.fromParts("package", context?.packageName, null)
intent.data = uri
startActivity(intent)
You can find documentation on it here.
As @ProgrAmmar pointed out, this was added in API level 33.
You can check for that like this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
// Your code for API level 33 or higher
// Enable your feature here
} else {
// Your code for API levels below 33
// Handle the case where the feature is not supported
}
The version code for API level 33 is TIRAMISU
but you can check the whole list of code names here.
Note: It is important that you consider building an alternative for your users when coding like this. For selecting an per-app language that might not be so important (as the users won't be missing it because no other app supports it either) but if there is functionality that is integral to your app, you should add an option for the other users or reconsider your approach.