When I use Xiaomi mobile phone, if a certain permission is denied, I will prompt you to turn it on. Click to enable it and jump to the permission setting interface of the app. Of course, this is the reason for the deep customization of the domestic system, which means that the original soundtrack of this interface does not have it! Here we use Xiaomi and Meizu as examples to explain how to enable users to manually open permissions. Of course, if it is an original android, let them jump to the application details settings page (it is a bit of a trick, because ordinary users still don’t know how to do it).
I have referenced many fragments of things, but the URL can no longer be found. . . . . .
OK, the first step is to jump to the system interface. You can basically consider it from 9, which can be simplified.
String SCHEME = "package"; //The Extra name required to call the system InstalledAppDetails interface (used for Android 2.1 and previous versions) final String APP_PKG_NAME_21 = ""; //The Extra name required to call the system InstalledAppDetails interface (for Android 2.2) final String APP_PKG_NAME_22 = "pkg"; //The package name where InstalledAppDetails is located final String APP_DETAILS_PACKAGE_NAME = ""; //InstalledAppDetails class name final String APP_DETAILS_CLASS_NAME = ""; Intent intent = new Intent(); final int apiLevel = .SDK_INT; if (apiLevel >= 9) { // 2.3 (ApiLevel 9) or above, use the interface provided by the SDK (Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = (SCHEME, getPackageName(), null); (uri); } else { // Below 2.3, use a non-public interface (see InstalledAppDetails source code) // In 2.2 and 2.1, the APP_PKG_NAME used by InstalledAppDetails is different. final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22 : APP_PKG_NAME_21); (Intent.ACTION_VIEW); (APP_DETAILS_PACKAGE_NAME, APP_DETAILS_CLASS_NAME); (appPkgName, getPackageName()); } (Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent);
The second one is miui, first of all, you have to judge that it is miui, test it yourself, MIUI7 stable version, MIUI8 development board is feasible, and the download will be provided below the tool class
if (()) { ("Product/hardware manufacturer Xiaomi:"); (".APP_PERM_EDITOR"); ("", ""); ("extra_pkgname", getPackageName()); (Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(intent); } catch (Exception e) { (); (, "Only MIUI can be set", Toast.LENGTH_SHORT).show(); } }
The third one is flying (because there is no flyme machine), using cloud mobile phone test
else if (()) { (".SHOW_APPSEC"); (Intent.CATEGORY_DEFAULT); ("packageName", getPackageName()); (Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(intent); } catch (Exception e) { (); (, "Only Flyme can be set", Toast.LENGTH_SHORT).show(); } }
Here are the tool classes: BuildProperties
public class BuildProperties { private final Properties properties; private BuildProperties() throws IOException { properties = new Properties(); (new FileInputStream(new File((), ""))); } public boolean containsKey(final Object key) { return (key); } public boolean containsValue(final Object value) { return (value); } public Set<<Object, Object>> entrySet() { return (); } public String getProperty(final String name) { return (name); } public String getProperty(final String name, final String defaultValue) { return (name, defaultValue); } public boolean isEmpty() { return (); } public Enumeration<Object> keys() { return (); } public Set<Object> keySet() { return (); } public int size() { return (); } public Collection<Object> values() { return (); } public static BuildProperties newInstance() throws IOException { return new BuildProperties(); }
CheckPhoneSystemUtils
private static final String KEY_MIUI_VERSION_CODE = ""; private static final String KEY_MIUI_VERSION_NAME = ""; private static final String KEY_MIUI_INTERNAL_STORAGE = ""; /** * Detect MIUI * * @return */ public static boolean isMIUI() { try { final BuildProperties prop = (); return (KEY_MIUI_VERSION_CODE, null) != null || (KEY_MIUI_VERSION_NAME, null) != null || (KEY_MIUI_INTERNAL_STORAGE, null) != null; } catch (final IOException e) { return false; } } /** * Detect Flyme * * @return */ public static boolean isFlyme() { try { // Invoke () final Method method = ("hasSmartBar"); return method != null; } catch (final Exception e) { return false; } }
The above solution to the permission setting interface for Android 6.0 or above permissions is all the content I share with you. I hope you can give you a reference and I hope you support me more.