Expo IntentLauncher无法打开Application_Details_Settings

时间:2019-11-28 14:03:52

标签: javascript react-native expo

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

我假设应该使用的代码是:

IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_DETAILS_SETTINGS)

但这给了我这个错误:

  

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

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

打开所有其他设置也可以,例如:

IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS)

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

1 个答案:

答案 0 :(得分:3)

我通过 bodolsog 找到了solution

完整解决方案

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 },
)

相关问题