https://github.com/lequanghuylc/react-native-detect-navbar-android
React Native module that tells if android device has soft navigation bar.
https://github.com/lequanghuylc/react-native-detect-navbar-android
android navigationbar react-native softkeyboard
Last synced: 5 days ago
JSON representation
React Native module that tells if android device has soft navigation bar.
- Host: GitHub
- URL: https://github.com/lequanghuylc/react-native-detect-navbar-android
- Owner: lequanghuylc
- License: mit
- Created: 2017-05-06T08:15:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-01-12T07:46:07.000Z (over 5 years ago)
- Last Synced: 2026-06-21T13:05:47.549Z (12 days ago)
- Topics: android, navigationbar, react-native, softkeyboard
- Language: Java
- Size: 10.1 MB
- Stars: 14
- Watchers: 1
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-detect-navbar-android
Detect soft navigation bar for Android devices, so you'll know which one has physical keys (Home, Back, Menu) and which does not.
Note: this project is Android only, and it will not work if you use it to detect soft key being hidden. Pull Request is welcomed.
## Installation Process
* download this from npm
```bash
npm install react-native-detect-navbar-android --save
```
* Run `react-native link` or...
* Edit `android/settings.gradle`:
```diff
+ include ':react-native-detect-navbar-android'
+ project(':react-native-detect-navbar-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-detect-navbar-android/android')
```
* Edit `android/app/build.gradle`:
```diff
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"
+ compile project(':react-native-detect-navbar-android')
}
```
* Edit your `android/app/src/main/java/.../MainApplication.java`:
```diff
+ import import com.rndetectnavbarandroid.RNDetectNavbarAndroidPackage;
```
```diff
@Override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage()
+ , new RNDetectNavbarAndroidPackage()
);
}
```
## Usage
```js
import DetectNavbar from 'react-native-detect-navbar-android';
// or
import {DetectNavbar} from 'react-native-detect-navbar-android';
// or
const DetectNavbar = require('react-native-detect-navbar-android');
// methods (Android Only, don't call on iOS)
DetectNavbar.hasSoftKeys().then((bool) => {
if(bool) {
console.log('Has Soft NavBar');
} else {
console.log('Has Hard Key NavBar');
}
});
```