Created
January 2, 2019 23:47
-
-
Save jsfan3/3397f1cf7853532ddc9c56a09aae8b3b to your computer and use it in GitHub Desktop.
Codename One Android Native Interface to access the app settings
This file contains 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
package net.informaticalibera.cn1.simpleapi; | |
import android.content.Context; | |
import android.content.Intent; | |
import android.net.Uri; | |
import android.provider.Settings; | |
public class AppSettingsUtilitiesImpl { | |
private static Context context() { | |
return com.codename1.impl.android.AndroidNativeUtil.getActivity().getApplicationContext(); | |
} | |
public void openAppSettings() { | |
// https://stackoverflow.com/questions/32822101/how-to-programmatically-open-the-permission-screen-for-a-specific-app-on-android | |
Intent intent = new Intent(); | |
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |
Uri uri = Uri.fromParts("package", context().getPackageName(), null); | |
intent.setData(uri); | |
context().startActivity(intent); | |
} | |
public boolean isSupported() { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment