App crash when ask for gps location (only android)
Issue Description
My app crash when ask for gps locations (ONLY ANDROID). The dialog box appears as expected and when i accept or decline the permission, my app crash with the follow error: Tried to use permissions API while not attached to an Activity. But even with error my app receive the permission, and if i re-open my app works fine.
I think that it is a wix problem beacuse my activity changes with react-native-navigation implementation.
After a lot of reading seems like there is an interface to implement permissions on android, but i can't figureout how to implement on my activity.
Steps to Reproduce / Code Snippets / Screenshots
Start app with tabs:
Navigation.startTabBasedApp({
tabs: [
{
label: 'Perfil',
screen: 'tab.profile',
icon: profileIcon,
navigatorStyle: {
navBarHidden: true,
navBarTextFontSize: 16
}
},
{
label: 'Paquerar',
screen: 'tab.main',
icon: heartIcon,
navigatorStyle: {
navBarHidden: true,
navBarTextFontSize: 16
}
},
{
label: 'Paqueras',
screen: 'tab.chat',
icon: paqueraIcon,
navigatorStyle: {
navBarHidden: true,
navBarTextFontSize: 16
}
}
],
tabsStyle: {
tabBarButtonColor: theme.palette.grayscale[1],
tabBarSelectedButtonColor: theme.palette.secondary,
tabBarBackgroundColor: theme.palette.white,
initialTabIndex: 1,
tabBarHideShadow: false,
},
appStyle: {
orientation: 'portrait',
hideBackButtonTitle: true ,
initialTabIndex: 1,
}
});
on main tab i ask for permission on componenetDidMount
try {
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
return true;
}
else{
return false;
}
}catch (err) {
}
On androidManifest
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- for Android 5.0 (API level 21) or higher. -->
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature android:name="android.hardware.location.network" />
MainActivity
package com.beachpaqueraapp;
import com.facebook.react.ReactActivity;
import com.reactnativenavigation.controllers.SplashActivity;
public class MainActivity extends SplashActivity {
protected String getMainComponentName() {
return "BeachPaqueraApp";
}
}
MainApplication
package com.beachpaqueraapp;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.reactnative.ivpusic.imagepicker.PickerPackage;
import com.bitgo.randombytes.RandomBytesPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.oblador.vectoricons.VectorIconsPackage;
import com.reactnativenavigation.NavigationApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends NavigationApplication implements ReactApplication {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new PickerPackage(),
new RandomBytesPackage(),
new LinearGradientPackage(),
new VectorIconsPackage()
);
}
@Override
public boolean isDebug() {
return BuildConfig.DEBUG;
}
@Override
public List<ReactPackage> createAdditionalReactPackages() {
return getPackages();
}
@Override
public String getJSMainModuleName() {
return "index";
}
}
### RESULT

Environment
- React Native Navigation version: 0.56.0
- React Native version: 1.1.480
- Platform(s) (iOS, Android, or both?): ANDROID
- Device info (Simulator/Device? OS version? Debug/Release?): DEBUG AND RELEASE. SIMULATOR: GENYMOTION NEXUS 6 (ANDROID 8) DEVICE: MOTO G4 (ANDROID 8) DEVICE: XIAOMI REDMI NOTE 5 (ANDROID 8.1)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.
The issue has been closed for inactivity.
same issue i am facing
@viniciusrangelfp how did you fix this issue?