Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expo IntentLauncher can't open Application_Details_Settings

I want to open the details settings of my application from the app itself. I use the IntentLauncher from Expo itself: https://docs.expo.io/versions/latest/sdk/intent-launcher

The code I use that I assume should work is:

IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_DETAILS_SETTINGS)

But this gives me this error:

[Unhandled promise rejection: Error: Encountered an exception while calling native method: Exception occurred while executing exported method startActivity on module ExpoIntentLauncher: null]

I'm not sure if I should give some kind of parameter with it so it links to my app?

Opening all other settings does work, ex:

IntentLauncher.startActivityAsync(IntentLauncher.ACTION_APPLICATION_SETTINGS)

This does open a list off all apps, I just need to get the detailed screen of the app itself, not the list.

like image 311
Raoul Avatar asked Nov 28 '19 14:11

Raoul


2 Answers

I found this solution by bodolsog working.

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

like image 54
mrBallista Avatar answered Oct 24 '22 21:10

mrBallista


Hope this helps someone

import { startActivityAsync, ActivityAction } from 'expo-intent-launcher';
import * as Linking from 'expo-linking';
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


openSettings = async () => {
    try {
      if (Platform.OS === 'android') {
        // console.log(Constants);
        startActivityAsync(ActivityAction.APPLICATION_DETAILS_SETTINGS, {
          data: 'package:' + pkg,
        });
      }
      if (Platform.OS === 'ios') {
        Linking.openSettings();
      }
    } catch (error) {
      console.log(error);
    }
  };
like image 40
SOG-web Avatar answered Oct 24 '22 20:10

SOG-web