Skip to content

Instantly share code, notes, and snippets.

@jsfan3
Created January 2, 2019 23:47
Show Gist options
  • Save jsfan3/3397f1cf7853532ddc9c56a09aae8b3b to your computer and use it in GitHub Desktop.
Save jsfan3/3397f1cf7853532ddc9c56a09aae8b3b to your computer and use it in GitHub Desktop.
Codename One Android Native Interface to access the app settings
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