Fix android module initialization
This commit is contained in:
parent
c840472d50
commit
a98401d47b
@ -5,16 +5,12 @@ import android.app.Application;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.ReactApplication;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.lang.Exception;
|
||||
|
||||
import org.json.JSONObject;
|
||||
@ -39,8 +35,10 @@ public class AppMetricaModule extends ReactContextBaseJavaModule {
|
||||
YandexMetrica.activate(getReactApplicationContext().getApplicationContext(), key);
|
||||
|
||||
Activity activity = getCurrentActivity();
|
||||
Application application = activity.getApplication();
|
||||
YandexMetrica.enableActivityAutoTracking(application);
|
||||
if (activity != null) {
|
||||
Application application = activity.getApplication();
|
||||
YandexMetrica.enableActivityAutoTracking(application);
|
||||
}
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
|
@ -1,21 +1,20 @@
|
||||
package com.aandrosov.AppMetrica;
|
||||
|
||||
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.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AppMetricaPackage implements ReactPackage {
|
||||
@Override
|
||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||
return Arrays.<NativeModule>asList(
|
||||
new AppMetricaModule(reactContext)
|
||||
);
|
||||
List<NativeModule> modules = new ArrayList<>();
|
||||
modules.add(new AppMetricaModule(reactContext));
|
||||
return modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user