react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

App crash when ask for gps location (only android)

Open viniciusrangelfp opened this issue 8 years ago • 4 comments

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 image image


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)

viniciusrangelfp avatar Oct 04 '18 19:10 viniciusrangelfp

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.

stale[bot] avatar Nov 26 '18 13:11 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Dec 03 '18 13:12 stale[bot]

same issue i am facing

umerbaig avatar Feb 08 '19 07:02 umerbaig

@viniciusrangelfp how did you fix this issue?

umerbaig avatar Feb 08 '19 07:02 umerbaig