【发布时间】:2020-06-22 10:04:52
【问题描述】:
【问题讨论】:
标签: android reactjs react-native permissions
【问题讨论】:
标签: android reactjs react-native permissions
如果你有 Native Java 知识,那么你必须在 React native 中使用 Native Modules 来使用 Native Java 代码
public void appDetailsSettings() {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setData(Uri.parse("package:" + reactContext.getPackageName()));
if (intent.resolveActivity(reactContext.getPackageManager()) != null) {
reactContext.startActivity(intent);
}
}
否则你可以使用第三方库,例如https://github.com/levelasquez/react-native-android-open-settings
【讨论】: