APP Adds CNZZ Statistics Plug in Tutorial Android edition adds phonegap

  • 2020-11-30 08:31:43
  • OfStack

KeyMob mobile advertising platform is a precise and stable advertising platform of SDK and mobile advertising, which is committed to shaping the most influential mobile advertising platform in China. Main mobile advertising services, across IOS, Android two platforms, including banner, insert, full-screen, video advertising, banner and other forms of advertising.
1. Import JAR package
For Eclipse developers, first unzip the downloaded ES10en.jar into the libs subdirectory under the local project directory (for example, your project directory is D:workspaceXXproject, put MobileProbe.jar into the D:workspaceXXprojectlibs directory), and then open the project project where your App application is developed in Eclipse.
From Package Explorer, right-click the project's root directory, select Properties, and then click Java Build Path - > Libraries - > Add External JARs, select the local MobileProbe. jar file, and finally click OK to import successfully.
2. Configuration AndroidManifest. xml
Version requirements:
android:minSdkVersion = 8: Support for Android 2.2 and above is required.

Permission requirements:

android. permission. ACCESS_NETWORK_STATE: Used to get the status of network links and send statistics. android.permission.ACCESS_WIFI_STATE: Used to obtain network link status and send statistics. android. permission. INTERNET: Used for network communication, sending statistics. android. permission. READ_PHONE_STATE: Used to get the hardware information of the mobile phone, mainly used to distinguish users. android. permission. ACCESS_COARSE_LOCATION: Used to obtain rough geographic information. (Optional, recommended)

Meta data:

CNZZ_APP_KEY: Please fill in App Key as obtained when registering App. CNZZ_CHANNEL_ID: You can fill in the corresponding channel name according to different distribution channels of App, which can be used for back-end statistics of the data published by the channel. (If you use the packaging tool to package automatically, do not fill in the channel name).

Code:


<manifest  ... > 
<uses-SDK android:minSdkVersion="8" android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.GET_TASKS"/> 
<uses-permission android:name="android.permission.INTERNET"></uses-permission> 
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission> 
<application  ... > 
<activity  ... /> 
<meta-data android:value="cnzz.a_6bf43dcde8e085951522422e" android:name="CNZZ_APP_KEY"></meta-data> 
<meta-data android:value="cnzz" android:name="CNZZ_CHANNEL_ID"></meta-data> 
</application> 
</manifest> 

1) Buried point of data collection
Introduce a data acquisition package into the code.
import com.cnzz.mobile.android.SDK.MobileProbe;
2). Basic statistics
Just call the corresponding collection function in the onCreate method in the program's entry Activity class. The other Activity does not need any embedding point:
MobileProbe. startStatistic (Activity activity, String appkey, String channel)
Parameters are: current Activity reference, application APPKEY, application channel.
Sample code:


Public class DemoActivity extends Activity{
Public void Create(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
MobileProbe.startStatistic(this, " cnzz.a_099b46617ca2180c7d741936 " , " cnzz " );
setContentView(R.layout.main);
}
}

3).phonegap can be added as follows:


public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
MobileProbe.startStatistic(this,"cnzz.a_qwv6we0tnlqkeu2qzp2wchrb","niulanapp"); 
super.setIntegerProperty("splashscreen", R.drawable.load); 
super.loadUrl("file:///android_asset/www/index.html", 3000); 
  }

3. The test
1. Whether to import JAR package correctly
2. Whether the correct permissions have been added to ES120en_NETWORK_ES124en, ACCESS_WIFI_STATE, INTERNET, READ_PHONE_STATE, GET_TASKS in ES120en.xml
3. Whether to call the startStatistic embedding function in the onCreate function of the main Activity class
4. Whether appkey was correctly filled in in the embedding function
5. Confirm the networking status of Android simulator (or test mobile phone)
6. Start the application and do one more attempt (switch pages, open and close the application)

KeyMob mobile advertising platform is a precise and stable advertising platform SDK and mobile advertising platform, which is committed to shaping the most influential mobile advertising platform in China. Main mobile advertising services, across the IOS, Android two platforms, including banner, insert, full-screen, video advertising, banner and other forms of advertising.

Above is the entire content of this article, I hope to help you learn, help you quickly install.


Related articles: