Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/garysye/react-native-android-geolocation
React Native Module to use Android Geolocation via Google Play API
https://github.com/garysye/react-native-android-geolocation
Last synced: 2 months ago
JSON representation
React Native Module to use Android Geolocation via Google Play API
- Host: GitHub
- URL: https://github.com/garysye/react-native-android-geolocation
- Owner: garysye
- Created: 2015-11-16T18:28:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-23T17:41:50.000Z (about 9 years ago)
- Last Synced: 2024-11-07T12:49:31.568Z (3 months ago)
- Language: Java
- Size: 119 KB
- Stars: 18
- Watchers: 8
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-react-native - react-native-android-geolocation ★19 - React Native Module to use Android Geolocation via Google Play API (Components / Geolocation)
- awesome-react-native-native-modules - react-native-android-geolocation ★18
- awesome-react-native - react-native-android-geolocation ★19 - React Native Module to use Android Geolocation via Google Play API (Components / Geolocation)
- awesome-react-native - react-native-android-geolocation ★19 - React Native Module to use Android Geolocation via Google Play API (Components / Geolocation)
- awesome-react-native-ui - react-native-android-geolocation ★17 - React Native Module to use Android Geolocation via Google Play API (Components / System)
- awesome-react-native - react-native-android-geolocation ★19 - React Native Module to use Android Geolocation via Google Play API (Components / Geolocation)
README
# react-native-android-geolocation
React Native Module to use Android Geolocation via Google Play API### Installation
```bash
npm install --save react-native-android-geolocation
```### Add it to your React Native android project
* In `android/setting.gradle`
```gradle
...
include ':RNAndroidGeolocation', ':app'
project(':RNAndroidGeolocation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-geolocation')
```* In `android/app/build.gradle`
```gradle
...
dependencies {
...
compile project(':RNAndroidGeolocation')
}
```* In `MainActivity.java`
```java
import com.rnandroidgeolocation.AndroidGeolocationPackage; // <--- Add import herepublic class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new AndroidGeolocationPackage()) // <--- Add package command here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();mReactRootView.startReactApplication(mReactInstanceManager, "ChewApp", null);
setContentView(mReactRootView);
}......
}
```### Google Play API Installation
In case you haven't done it already, you will also need to install the corresponding Google Play SDK. To do this run
```bash
$ cd /path/to/your/android-sdk/tools
$ android sdk
```and select the Google Play SDK extras as pictured below:
![Google Play SDK Installation](./google-play-installation.png)
## Example
```javascript
var AndroidGeolocation = require('react-native-android-geolocation');AndroidGeolocation.getCurrentLocation(
(position) => this.setState({position: position}),
(error) => this.setState({error: error})
);
```
## LicenseISC