Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.yourapp.navbar;
import android.app.Activity;
import android.view.View;
import com.facebook.react.ReactActivity;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
public class NavigationBarAndroid extends ReactContextBaseJavaModule {
public NavigationBarAndroid(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return "NavigationBarAndroid";
}
@ReactMethod
public void hide() {
Activity reactActivity = getCurrentActivity();
if (reactActivity) {
View decorView = reactActivity.getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
}
}
package com.yourapp.navbar;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class NavigationBarAndroidPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new NavigationBarAndroid(reactContext));
return modules;
}
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
@Jijuan

This comment has been minimized.

Copy link

Jijuan commented Apr 16, 2017

line 25 in NavigationBarAndroid.java, should be changed to if(reactActivity != null).

@Jijuan

This comment has been minimized.

Copy link

Jijuan commented Apr 16, 2017

And, the method 'hide' sould be changed to use 'startActivityForResult'. This is because we use 'MainApplication' not 'MainActivity'.

@nateblog

This comment has been minimized.

Copy link

nateblog commented Aug 21, 2017

Hi good day, please help on how to implement the code properly. I am currently having an error under NavigationBarAndroidPackage.java line 25 saying it can not override.

@nateblog

This comment has been minimized.

Copy link

nateblog commented Aug 21, 2017

I managed to take away the error but still not working, the navigation is still showing

@Donhv

This comment has been minimized.

Copy link

Donhv commented Feb 26, 2018

@Jijuan can u show me full code NavigationBarAndroid.java

@vwnb

This comment has been minimized.

Copy link

vwnb commented May 23, 2018

@Jijuan I would also be very interested, if you have the time. Or anyone else who knows native Android code well enough to construct those changes? Blindly jumping into using startActivityForResult isn't yielding much result :(

@hto

This comment has been minimized.

Copy link

hto commented Mar 13, 2019

You can also try this. (I'm use React Native Wix Navigation V2.)
https://gist.github.com/hto/7ed5ef629bd8bdf651c73f3680541ad5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.