Add phonegap for Android – add cnzz statistics plug-in tutorial for app

Here is the programming house jb51 CC collects and arranges code fragments through the network.

Programming house Xiaobian now shares it with you and gives you a reference.

一:导入jar包
使用Eclipse进行开发的用户,首先将下载的MobileProbe.jar解压到本地工程目录下的libs子目录里面(例如,您的工程目录为,D:workspaceXXproject,请将MobileProbe.jar放入D:workspaceXXprojectlibs目录中),然后在Eclipse中打开您开发的App应用所在项目工程。 

在Package Explorer中右键点击工程的根目录,选择Properties,然后点击Java Build Path -> Libraries -> Add External JARs,选择本地的MobileProbe.jar文件,最后点击OK,即可导入成功。


二:配置AndroidManifest.xml
版本要求:
android:minSdkVersion = 8:需要Android 2.2及以上版本支持。
权限要求:
android.permission.ACCESS_NETWORK_STATE:用于获取网络链接状态,发送统计数据。 
android.permission.ACCESS_WIFI_STATE:用于获取网络链接状态,发送统计数据。 
android.permission.INTERNET:用于网络通信,发送统计数据。 
android.permission.READ_PHONE_STATE:用于获取手机的硬件信息,主要用于区分用户。 
android.permission.ACCESS_COARSE_LOCATION:用于获取粗略的地理信息。(可选,推荐) 
Meta数据:
CNZZ_APP_KEY:请填入注册App时得到的App Key。 
CNZZ_CHANNEL_ID:可以根据App不同的发行渠道填入相应的渠道名称,用于后端统计渠道发布的数据。 (如果您使用打包工具自动打包,可不填渠道名称)。
代码:
<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.数据采集埋点
在代码中引入数据采集包。 
import com.cnzz.mobile.android.SDK.MobileProbe;
 
2.基本统计 
只需在程序的入口Activity类中的onCreate方法中调用对应的采集函数,其他Activity不需要进行任何埋点:
MobileProbe. startStatistic (Activity activity,String appkey,String channel)
参数为:当前Activity的引用,应用的APPKEY,应用渠道。
示例代码:
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下面这样添加即可:
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); 
    }


三:测试
是否正确导入jar包
是否在Androidmanifest.xml中添加了正确的权限:ACCESS_NETWORK_STATE、ACCESS_WIFI_STATE、INTERNET、READ_PHONE_STATE、GET_TASKS。
是否在主Activity类的onCreate函数中都调用startStatistic埋点函数
是否在埋点函数中正确的填写了appkey
确认Android模拟器(或测试手机)联网状态
启动应用程序,多做一些尝试操作(切换页面,打开关闭应用程序)


KeyMob移动广告平台是精准稳定的广告SDK、移动广告平台,致力于塑造国内最具有影响力的移动广告平台。主营移动广告服务,横跨IOS、Android两大平台,包含横幅、插屏、全屏、视频广告、banner等多种广告形式。

The above is all the code content collected by the programming home (jb51. CC). I hope this article can help you solve the program development problems you encounter.

If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>