使用React Native Liniking.openURL()打开Intent android.provider.Settings.ACTION_WIFI_SETTINGS

2w2cym1i  于 2023-04-07  发布在  React
关注(0)|答案(1)|浏览(190)

如何使用Linking.openURL()在react native中打开Android Intent。例如如何打开Android的WIFI设置菜单。

qq24tv8q

qq24tv8q1#

你能用一些像

async function goToSettings(ios: string = 'WIFI', android: string = 'android.settings.WIFI_SETTINGS') {
  if (Platform.OS === 'ios') {
    // https://medium.com/@contact.jmeyers/complete-list-of-ios-url-schemes-for-apple-settings-always-updated-20871139d72f
    await Linking.openURL(`prefs:root=${ios}`);
  }
  // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/provider/Settings.java
  await Linking.sendIntent(`android.settings.${android}`);
}

相关问题