Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Useful if you want to capture listen for `BackButton` press and pause your appli
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
.addPackage(new ActivityAndroidPackage(this)) // <---- Add here
.addPackage(new ActivityAndroidPackage()) // <---- Add here
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ android {
}

dependencies {
compile 'com.facebook.react:react-native:0.11.+'
compile 'com.facebook.react:react-native:0.33.+'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? The latest version should be 0.20.1 according to https://mvnrepository.com/artifact/com.facebook.react/react-native. PR #3 seems to be the correct fix. Note also that these changes have been required since RN 0.29.0.

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
import com.facebook.react.bridge.ReactMethod;

public class ActivityAndroidModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
private Activity mCurrentActivity;

public ActivityAndroidModule(ReactApplicationContext reactContext, Activity activity) {
public ActivityAndroidModule(ReactApplicationContext reactContext) {
super(reactContext);
mCurrentActivity = activity;
reactContext.addLifecycleEventListener(this);
}

Expand All @@ -30,7 +27,7 @@ public String getName() {

@ReactMethod
public void moveTaskToBack(Callback onSuccess, Callback onError) {
boolean wasMoved = mCurrentActivity.moveTaskToBack(true);
boolean wasMoved = getCurrentActivity().moveTaskToBack(true);

if (wasMoved) {
onSuccess.invoke();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
import java.util.List;

public class ActivityAndroidPackage implements ReactPackage {
private Activity mCurrentActivity;
public ActivityAndroidPackage() {

public ActivityAndroidPackage(Activity activity) {
mCurrentActivity = activity;
}

@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(
new ActivityAndroidModule(reactContext, mCurrentActivity)
new ActivityAndroidModule(reactContext)
);
}

Expand Down