File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed
android/src/main/java/com/bleplx Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change 1
1
package com .bleplx ;
2
2
3
- import android .app .Activity ;
4
-
5
3
import androidx .annotation .NonNull ;
6
4
import androidx .annotation .Nullable ;
7
5
52
50
@ ReactModule (name = BlePlxModule .NAME )
53
51
public class BlePlxModule extends ReactContextBaseJavaModule {
54
52
public static final String NAME = "BlePlx" ;
53
+ private final ReactApplicationContext reactContext ;
55
54
56
55
public BlePlxModule (ReactApplicationContext reactContext ) {
57
56
super (reactContext );
57
+ this .reactContext = reactContext ;
58
58
RxJavaPlugins .setErrorHandler (throwable -> {
59
59
if (throwable instanceof UndeliverableException ) {
60
60
RxBleLog .e ("Handle all unhandled exceptions from RxJava: " + throwable .getMessage ());
@@ -98,11 +98,7 @@ public Map<String, Object> getConstants() {
98
98
99
99
@ ReactMethod
100
100
public void createClient (String restoreStateIdentifier ) {
101
- final Activity activity = getCurrentActivity ();
102
- if (activity == null ) {
103
- return ;
104
- }
105
- bleAdapter = BleAdapterFactory .getNewAdapter (activity );
101
+ bleAdapter = BleAdapterFactory .getNewAdapter (reactContext );
106
102
bleAdapter .createClient (restoreStateIdentifier ,
107
103
new OnEventCallback <String >() {
108
104
@ Override
You can’t perform that action at this time.
0 commit comments