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