React-native integrates Umeng statistics function android

React-native integrates Umeng statistics function android

Download the file ( developer.umeng.com/sdk )

After downloading, unzip it, just use this one, there are all in it

android

1. Put the two jar packages in the android file directory in the downloaded file

Add to the project android/app/libs, create a new one without libs

2. Add the jar package to android/app/build.gradle, pay attention to the name inside to be consistent with the downloaded jar package name

3. Open AndroidManifest.xml, add

4. Put these downloaded interactive Java files into the project. Here I created a new folder and put it in the same level directory as MainApplication.java

Change the package name in the file to your own, all three java files must be changed

5. Open MainApplication.java

Import the file, follow the java file path just added

Add new DplusReactPackage() to the protected List getPackages

add in onCreate

    RNUMConfigure.init(this, " appkey", "UMENG_CHANNEL", UMConfigure.DEVICE_TYPE_PHONE,"");
 

6.MainActivity.java

 @Override    protected void onCreate(Bundle savedInstanceState) {       //umeng         MobclickAgent.setSessionContinueMillis(100);  //        super.onCreate(savedInstanceState);      
    }  @Override    public void onResume() {  //        super.onResume();        MobclickAgent.onResume(this);    }    @Override    protected void onPause() {//        super.onPause();        MobclickAgent.onPause(this);    }
 

Introduce import com.umeng.analytics.MobclickAgent; if it is not right, find the corresponding one in the downloaded .java file