在 React Native 中与 android os 设置链接
问题描述:
我正在尝试链接 android os settings
页面.
I'm trying to link with android os settings
page.
使用 Linking
转到 Phone Dail
是可行的.
Going to Phone Dail
with Linking
is work.
Linking.openURL('tel: +959 XXXXXXXX');
我可以使用Linking
链接到android os settings
页面,比如android location settings
页面吗?
Can I use Linking
to link with android os settings
page like android location settings
page?
答
Linking.openURL
只能打开格式正确的 url.android 设置没有标准化的网址.您必须编写一些本机代码来执行此操作,然后构建一个 响应本机模块以触发它.
Linking.openURL
can only open correctly formatted urls. There are no standardized urls for the android settings. You would have to write some native code to do this, and then build a React Native Module to trigger it.
以下是一些 Android 代码示例:
Here is some example Android code:
public void openWifiSettings() {
Intent intent = new Intent(Intent.ACTION_WIFI_SETTINGS);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
}