{"action":"closed","issue":{"url":"https://api.github.com/repos/wix/react-native-navigation/issues/4095","repository_url":"https://api.github.com/repos/wix/react-native-navigation","labels_url":"https://api.github.com/repos/wix/react-native-navigation/issues/4095/labels{/name}","comments_url":"https://api.github.com/repos/wix/react-native-navigation/issues/4095/comments","events_url":"https://api.github.com/repos/wix/react-native-navigation/issues/4095/events","html_url":"https://github.com/wix/react-native-navigation/issues/4095","id":366930232,"node_id":"MDU6SXNzdWUzNjY5MzAyMzI=","number":4095,"title":"App crash when ask for gps location (only android)","user":{"login":"viniciusrangelfp","id":29734167,"node_id":"MDQ6VXNlcjI5NzM0MTY3","avatar_url":"https://avatars1.githubusercontent.com/u/29734167?v=4","gravatar_id":"","url":"https://api.github.com/users/viniciusrangelfp","html_url":"https://github.com/viniciusrangelfp","followers_url":"https://api.github.com/users/viniciusrangelfp/followers","following_url":"https://api.github.com/users/viniciusrangelfp/following{/other_user}","gists_url":"https://api.github.com/users/viniciusrangelfp/gists{/gist_id}","starred_url":"https://api.github.com/users/viniciusrangelfp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/viniciusrangelfp/subscriptions","organizations_url":"https://api.github.com/users/viniciusrangelfp/orgs","repos_url":"https://api.github.com/users/viniciusrangelfp/repos","events_url":"https://api.github.com/users/viniciusrangelfp/events{/privacy}","received_events_url":"https://api.github.com/users/viniciusrangelfp/received_events","type":"User","site_admin":false},"labels":[{"id":951487479,"node_id":"MDU6TGFiZWw5NTE0ODc0Nzk=","url":"https://api.github.com/repos/wix/react-native-navigation/labels/%F0%9F%8F%9A%20stale","name":"🏚 stale","color":"e6e6e6","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-04T19:11:01Z","updated_at":"2018-12-03T13:52:08Z","closed_at":"2018-12-03T13:52:08Z","author_association":"NONE","body":"<!--\r\n https://stackoverflow.com/questions/52653613/app-crash-when-ask-for-gps-location-only-android\r\n-->\r\n\r\n### Issue Description\r\nMy app crash when ask for gps locations (ONLY ANDROID).\r\nThe 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.\r\nBut even with error my app receive the permission, and if i re-open my app works fine.\r\n\r\nI think that it is a wix problem beacuse my activity changes with react-native-navigation implementation.\r\n\r\nAfter 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.\r\n\r\n### Steps to Reproduce / Code Snippets / Screenshots\r\n\r\nStart app with tabs:\r\n ```\r\nNavigation.startTabBasedApp({\r\n        tabs: [\r\n            {\r\n                label: 'Perfil',\r\n                screen: 'tab.profile',\r\n                icon: profileIcon, \r\n                navigatorStyle: {\r\n                    navBarHidden: true,\r\n                    navBarTextFontSize: 16\r\n                }\r\n            },\r\n            {\r\n                label: 'Paquerar',\r\n                screen: 'tab.main',\r\n                icon: heartIcon, \r\n                navigatorStyle: {\r\n                    navBarHidden: true,\r\n                    navBarTextFontSize: 16\r\n                }\r\n            },\r\n            {\r\n                label: 'Paqueras',\r\n                screen: 'tab.chat',\r\n                icon: paqueraIcon, \r\n                navigatorStyle: {\r\n                    navBarHidden: true,\r\n                    navBarTextFontSize: 16\r\n                }\r\n            }\r\n        ],\r\n        tabsStyle: { \r\n            tabBarButtonColor: theme.palette.grayscale[1],\r\n            tabBarSelectedButtonColor: theme.palette.secondary,\r\n            tabBarBackgroundColor: theme.palette.white,\r\n            initialTabIndex: 1,\r\n            tabBarHideShadow: false,\r\n        },\r\n        appStyle: {\r\n            orientation: 'portrait',\r\n            hideBackButtonTitle: true ,\r\n            initialTabIndex: 1,\r\n        }\r\n    });\r\n```\r\n\r\non main tab i ask for permission on componenetDidMount\r\n```\r\ntry {\r\n            const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION);\r\n           \r\n            if (granted === PermissionsAndroid.RESULTS.GRANTED) {\r\n                return true;\r\n            }\r\n            else{\r\n               return false;\r\n            }\r\n        }catch (err) {\r\n\r\n        }\r\n```\r\n\r\nOn androidManifest \r\n```\r\n<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" />\r\n    <uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />\r\n\r\n     <!-- for Android 5.0 (API level 21) or higher. -->\r\n    <uses-feature android:name=\"android.hardware.location.gps\" />\r\n    <uses-feature android:name=\"android.hardware.location.network\" />\r\n```\r\n\r\nMainActivity\r\n```\r\npackage com.beachpaqueraapp;\r\n\r\nimport com.facebook.react.ReactActivity;\r\nimport com.reactnativenavigation.controllers.SplashActivity;\r\n\r\n\r\npublic class MainActivity extends SplashActivity {\r\n\r\n    protected String getMainComponentName() {\r\n        return \"BeachPaqueraApp\";\r\n    }\r\n\r\n}\r\n```\r\n\r\n\r\nMainApplication\r\n```\r\npackage com.beachpaqueraapp;\r\n\r\nimport android.app.Application;\r\n\r\nimport com.facebook.react.ReactApplication;\r\nimport com.reactnative.ivpusic.imagepicker.PickerPackage;\r\nimport com.bitgo.randombytes.RandomBytesPackage;\r\nimport com.BV.LinearGradient.LinearGradientPackage;\r\nimport com.oblador.vectoricons.VectorIconsPackage;\r\nimport com.reactnativenavigation.NavigationApplication;\r\nimport com.facebook.react.ReactNativeHost;\r\nimport com.facebook.react.ReactPackage;\r\nimport com.facebook.react.shell.MainReactPackage;\r\nimport com.facebook.soloader.SoLoader;\r\n\r\n\r\nimport java.util.Arrays;\r\nimport java.util.List;\r\n\r\npublic class MainApplication extends NavigationApplication implements ReactApplication {\r\n\r\n\r\n  protected List<ReactPackage> getPackages() {\r\n    return Arrays.<ReactPackage>asList(\r\n        new MainReactPackage(),\r\n            new PickerPackage(),\r\n            new RandomBytesPackage(),\r\n            new LinearGradientPackage(),\r\n            new VectorIconsPackage()\r\n    );\r\n  }\r\n\r\n  @Override\r\n\tpublic boolean isDebug() {\r\n    return BuildConfig.DEBUG;\r\n\t}\r\n\r\n  @Override\r\n\tpublic List<ReactPackage> createAdditionalReactPackages() {\r\n\t\treturn getPackages();\r\n\t}\r\n\r\n    @Override\r\n\tpublic String getJSMainModuleName() {\r\n\t\treturn \"index\";\r\n\t}\r\n\r\n}\r\n```\r\n\r\n\r\n**### RESULT**\r\n![image](https://user-images.githubusercontent.com/29734167/46496853-6e832600-c7ef-11e8-8c5a-860e69fbcc4d.png)\r\n![image](https://user-images.githubusercontent.com/29734167/46496869-79d65180-c7ef-11e8-99da-13801fb17c84.png)\r\n\r\n---\r\n### Environment\r\n* React Native Navigation version: 0.56.0\r\n* React Native version: 1.1.480\r\n* Platform(s) (iOS, Android, or both?): ANDROID\r\n* Device info (Simulator/Device? OS version? Debug/Release?): DEBUG AND RELEASE. \r\nSIMULATOR: GENYMOTION NEXUS 6 (ANDROID 8)\r\nDEVICE: MOTO G4 (ANDROID 8)\r\nDEVICE: XIAOMI REDMI NOTE 5 (ANDROID 8.1)\r\n"}}
{"actor":{"display_login":"stale"}}