Expo IntentLauncher 无法打开 Application_Details_Settings

Rao*_*oul 6 javascript react-native expo

我想从应用程序本身打开我的应用程序的详细信息设置。我使用 Expo 本身的 IntentLauncher:https ://docs.expo.io/versions/latest/sdk/intent-launcher

我使用的我认为应该工作的代码是:

IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_DETAILS_SETTINGS)
Run Code Online (Sandbox Code Playgroud)

但这给了我这个错误:

[未处理的承诺拒绝:错误:调用本机方法时遇到异常:在模块 ExpoIntentLauncher 上执行导出方法 startActivity 时发生异常:空]

我不确定我是否应该给它提供某种参数,以便它链接到我的应用程序?

打开所有其他设置确实有效,例如:

IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS)
Run Code Online (Sandbox Code Playgroud)

这确实会打开所有应用程序的列表,我只需要获取应用程序本身的详细屏幕,而不是列表。

mrB*_*sta 6

我通过bodolsog工作找到了这个解决方案

完整的解决方案

import * as IntentLauncher from "expo-intent-launcher";
import Constants from "expo-constants";

const pkg = Constants.manifest.releaseChannel
      ? Constants.manifest.android.package  // When published, considered as using standalone build
      : "host.exp.exponent"; // In expo client mode

IntentLauncherAndroid.startActivityAsync(
  IntentLauncherAndroid.ACTION_APPLICATION_DETAILS_SETTINGS,
  { data: 'package:' + pkg },
)

Run Code Online (Sandbox Code Playgroud)

  • 也许由于更新,我被迫更改最后一次调用以使用 IntentLauncher.ActivityAction.APPLICATION_DETAILS_SETTINGS (2认同)