用户工具

站点工具


这是本文档旧的修订版!


Cobub Razor Android Developer Guide

1 Overview

1.1 Documentation Goal

The goal of this document is to explain usage rules of Cobub Razor Android SDK for facilitating developers.

1.2 Application Scope

This document is for Android SDK developers, who use the Open Source Mobile Analytics – Cobub Razor.

1.3 Terms and Abbreviations

2 Basic Setup Guide

2.1 Register App,Obtain AppKey,Download Developer Documentation

First please setup the Web Server of Cobub Razor (instruction), then register App on web server and fill App info after login. Once App is created successfully, you could obtain AppKey.

2.2 SDK Usage Step

2.2.1 Import com.wbkit1.0.jar

Open android_sdk in the directory you uploaded on the server. Import android_sdk to Eclipse and Eclipse will compile src and produce a bin folder. Zip the com folder in bin\classes as com.wbkit1.0.jar. Eclipse users right click own project root directory and select Properties —>Java Build Path —>libraries. Then click Add External JARs and select path of com.wbkit1.0.jar. Finally, click OK and then import is completed.

2.2.2 Configure AndroidManifest.xml

  • Add App AppKey (mandatory)

Add AppKey obtained by App to meta-data of AndroidManifest.xml.

(Note: String must be ‘UMS_APPKEY‘)

  • Add permission android.permission.INTERNET (mandatory)

Send user analytic data to server.

  • Add permission android.permission.READ_PHONE_STATE (mandatory)

Obtain relevant status info of phone.

  • Add permission android.permission.ACCESS_FINE_LOCATION (mandatory)

Obtain current user’s location info.

  • Add permission android.permission.ACCESS_WIFI_STATE (mandatory)

Visit Wi-Fi network status info.

  • Add permission android.permission.GET_TASKS (mandatory)

Obtain recent running task info.

  • Add permission android.permission.WRITE_EXTERNAL_STORAGE (mandatory)

Read and write file to sdcard.

  • Add permission android.permission.READ_LOGS(mandatory)

Read program error log.

  • Add permission android.permission.ACCESS_NETWORK_STATE(mandatory)

Visit GSM network info.

The AndroidManifest.xml file as shown below:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
 	
package="com.wbtech.test_sample" 	 	 
android:versionCode="1" 	 	 
android:versionName="1.0" > 	 	 
<uses-sdk 	 	 
android:minSdkVersion="8" 	 	 
android:targetSdkVersion="15" /> 	 	 
<uses-permission android:name="android.permission.INTERNET"/> 	 	 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 	 	 
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> 	 	 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 	 	 
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 	 	 
<uses-permission android:name="android.permission.GET_TASKS"/> 	 	 
<uses-permission android:name="android.permission.READ_LOGS"/> 	 	 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 	 	 
<application 	 	 
android:icon="@drawable/ic_launcher" 	 	 
android:label="@string/app_name" 	 	 
android:theme="@style/AppTheme" > 	 	 
<activity 	 	 
android:name=".MainActivity" 	 	 
android:label="@string/title_activity_main" > 	 	 
<intent-filter> 	 	 
<action android:name="android.intent.action.MAIN" /> 	 	 
<category android:name="android.intent.category.LAUNCHER" /> 	 	 
</intent-filter> 	 	 
</activity> 	 	 
<meta-data android:name="UMS_APPKEY" android:value="bb08202a625c2b5cae5e2632f604352f "/> 	 	 
</application> 	 	 
</manifest>

2.2.3 Add Code

* Add Reference

      import com.wbtech.ums.UmsAgent;

Set web server URL

      Call UmsAgent.setBaseURL(String url)in onCreate() method of App enter Activity, note that this method should be placed before  all other methods.

* Obtain UserID

      Call UmsAgent.bindUserIdentifier(String userID) method where you can obtain the unique identifier of user,   and this method will record the userID on behalf of the user of using this application.

* Bind Tags

      Call UmsAgent.postTags(final Context context, final String tags) method where you can obtain the attributes to tag the user. The tag values will be sent to server.

* Register Activity

      Call UmsAgent.onResume(Context) in onResume method of every Activity. The passed parameter is the reference of current context. This method will read AppKey from AndroidManifest.xml automatically and record the time of user enters into this activity. Do not pass global application context. 
en/razor/android-developer-guide.1426663631.txt.gz · 最后更改: 2017/07/14 11:12 (外部编辑)