Skip to content

Commit

Permalink
fix: use proper context instead of activity (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
g4rb4g3 committed Aug 27, 2024
1 parent 1814f4a commit 99b33b7
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions android/src/main/java/com/bleplx/BlePlxModule.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.bleplx;

import android.app.Activity;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

Expand Down Expand Up @@ -52,9 +50,11 @@
@ReactModule(name = BlePlxModule.NAME)
public class BlePlxModule extends ReactContextBaseJavaModule {
public static final String NAME = "BlePlx";
private final ReactApplicationContext reactContext;

public BlePlxModule(ReactApplicationContext reactContext) {
super(reactContext);
this.reactContext = reactContext;
RxJavaPlugins.setErrorHandler(throwable -> {
if (throwable instanceof UndeliverableException) {
RxBleLog.e("Handle all unhandled exceptions from RxJava: " + throwable.getMessage());
Expand Down Expand Up @@ -98,11 +98,7 @@ public Map<String, Object> getConstants() {

@ReactMethod
public void createClient(String restoreStateIdentifier) {
final Activity activity = getCurrentActivity();
if (activity == null) {
return;
}
bleAdapter = BleAdapterFactory.getNewAdapter(activity);
bleAdapter = BleAdapterFactory.getNewAdapter(reactContext);
bleAdapter.createClient(restoreStateIdentifier,
new OnEventCallback<String>() {
@Override
Expand Down

0 comments on commit 99b33b7

Please sign in to comment.