用户工具

站点工具


差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
后一修订版 两侧同时换到之后的修订记录
en:razor:android-developer-guide [2015/09/11 14:36]
cobub v0.7.1
en:razor:android-developer-guide [2015/09/15 10:36]
cobub
行 2: 行 2:
 {{description>​Cobub Razor is an Open Source Mobile Analytics. The goal of this document is to explain usage rules of Cobub Razor Android ​ SDK for facilitating developers.}} {{description>​Cobub Razor is an Open Source Mobile Analytics. The goal of this document is to explain usage rules of Cobub Razor Android ​ SDK for facilitating developers.}}
 {{keywords>​Cobub Razor,open source mobile analytics,​mobile analytics,​mobile app analytics, android, developer guide, setup, configuration}} {{keywords>​Cobub Razor,open source mobile analytics,​mobile analytics,​mobile app analytics, android, developer guide, setup, configuration}}
-v0.7.1+
 ====== Cobub Razor Android Developer Guide ====== ====== Cobub Razor Android Developer Guide ======
- 
  
 ===== 1   ​Overview ===== ===== 1   ​Overview =====
- 
  
 ==== 1.1   ​Documentation Goal ==== ==== 1.1   ​Documentation Goal ====
- 
  
 The goal of this document is to explain usage rules of Cobub Razor Android ​ SDK for facilitating developers. The goal of this document is to explain usage rules of Cobub Razor Android ​ SDK for facilitating developers.
行 35: 行 32:
  
  
-=== 2.2.1   ​Import ​com.wbkit1.0.jar ===+=== 2.2.1   ​Import ​sdk jar ===
  
 +Open android_sdk in the directory you uploaded on the server. ​ Import android_sdk to Eclipse and export sdk jar file. 
  
-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.+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 === === 2.2.2   ​Configure AndroidManifest.xml ===
行 108: 行 106:
 * Add Reference * Add Reference
         import com.wbtech.ums.UmsAgent;​         import com.wbtech.ums.UmsAgent;​
-Set web server URL +Init  
-        Call UmsAgent.setBaseURL(String url)in onCreate() method of App enter Activity, ​note that this method ​should ​be placed ​before ​ ​all ​other methods.+        Call UmsAgent.init(Context context, ​String url)in onCreate() method of App enter Activity, ​make sure that this method be called ​before other methods. The url parameter should be ended with "​index.php?",​ like "​http://​demo.cobub.com/​razor/​index.php?"​.
 * Obtain UserID * 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.+        Call UmsAgent.bindUserid(Context context, ​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 * 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.         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 * 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. ​         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. ​
- 
  
 <​code>​protect void onResume(){ <​code>​protect void onResume(){
行 124: 行 121:
  
 Call UmsAgent.onPause(Context) in onPause method of every Activity. Parameter is the reference of current context. This method will record the time of user leaves this activity. Call UmsAgent.onPause(Context) in onPause method of every Activity. Parameter is the reference of current context. This method will record the time of user leaves this activity.
- 
- 
- 
  
 <​code>​protected void onPause(){ <​code>​protected void onPause(){
行 133: 行 127:
 }</​code>​ }</​code>​
 Call UmsAgent.postClientData(Context) ​ in onCreate method of every Activity. Parameter is the reference of current context. Call UmsAgent.postClientData(Context) ​ in onCreate method of every Activity. Parameter is the reference of current context.
- 
- 
- 
  
 <​code>​public void onCreate (Bundle savedInstanceState){ <​code>​public void onCreate (Bundle savedInstanceState){
行 148: 行 139:
     setContentView(R.layout.activity_main);​     setContentView(R.layout.activity_main);​
     button = (Button) findViewById(R.id.button1);​     button = (Button) findViewById(R.id.button1);​
-    UmsAgent.setBaseURL("​http://​192.168.1.204/UMS/​index.php?"​);​+    UmsAgent.init(this."​http://​demo.cobub.com/razor/​index.php?"​);​
     UmsAgent.update(this);​     UmsAgent.update(this);​
-    ​UmsAgent.onError(this);​ +    UmsAgent.setDefaultReportPolicy(this, ​SendPolicy.REALTIME); 
-    ​UmsAgent.setDefaultReportPolicy(this, ​1); +    UmsAgent.bindUserid(this, "cobub.open@gmail.com");
-    UmsAgent.bindUserIdentifier(this, "xd.."); +
-    UmsAgent.postClientData(this);+
     button.setOnClickListener(new OnClickListener() {     button.setOnClickListener(new OnClickListener() {
  
行 167: 行 156:
  
 === 2.2.4   ​Integration Instructions === === 2.2.4   ​Integration Instructions ===
- 
- 
  
 We recommend you call **UmsAgent.onResume()** and **UmsAgent.onPause()** in all activities. ​ If not,  Page View report and some related reports will not be available on the Web Server. We recommend you call **UmsAgent.onResume()** and **UmsAgent.onPause()** in all activities. ​ If not,  Page View report and some related reports will not be available on the Web Server.
- 
  
 === 2.2.5   Note === === 2.2.5   Note ===
     * AppKey     * AppKey
-Check to make sure that AppKey has been corrently ​written to Androidmanifest.xml.+Check to make sure that AppKey has been correctly ​written to Androidmanifest.xml.
     * Permission     * Permission
 Check to make sure that all required permissions have been added. Check to make sure that all required permissions have been added.
行 182: 行 168:
     * Check Network     * Check Network
 Check to make sure that test phone or simulator has successfully connected to network. Check to make sure that test phone or simulator has successfully connected to network.
- 
  
 ===== 3   ​Advanced Setup Guide ===== ===== 3   ​Advanced Setup Guide =====
行 203: 行 188:
  
 ==== 3.2   ​Custom Event ==== ==== 3.2   ​Custom Event ====
- 
- 
  
 Except basic data statistics analysis, the SDK also support analysis of custom event. For example, you could count ad clicks or times of  video has been played. Here we provide several simple and common interfaces: Except basic data statistics analysis, the SDK also support analysis of custom event. For example, you could count ad clicks or times of  video has been played. Here we provide several simple and common interfaces:
行 221: 行 204:
  
 in App to notify server that an AD click event  has occurred. in App to notify server that an AD click event  has occurred.
- 
  
 UmsAgent.onEvent(Context context,​String event_id,​int acc) UmsAgent.onEvent(Context context,​String event_id,​int acc)
  
 For the frequent events, you can maintain a counter for them . In this way, event that are triggered by many times will  just need generate one message. This message includes triggered times of this event. Here is overloaded two APIs: For the frequent events, you can maintain a counter for them . In this way, event that are triggered by many times will  just need generate one message. This message includes triggered times of this event. Here is overloaded two APIs:
- 
  
 UmsAgent.onEvent(Context context,​String event_id,​int acc) UmsAgent.onEvent(Context context,​String event_id,​int acc)
行 239: 行 220:
  
  
-==== 3.3 Channel Analytics ​====+==== 3.3 Debug ====
  
- +Cobub Android SDK provides the Debug function, which can help developers to locate problems. Developers can enable debug function and set the different log level: 
- +<code java> 
-Different channels have different AppKeysdata statistics analytics results could help you make a good understanding of how many users have downloaded your App from Lenovo park or Google Android market+UmsAgent.setDebugEnabled(true);​ 
 +UmsAgent.setDebugLevel(UmsAgent.LogLevel);​ 
 +</​code>​  
 +LogLevel has five levels:​Info,​ Debug, Warn, Error, Verbose.
  
 ===== 4   App Update ===== ===== 4   App Update =====
 ==== 4.1   ​Upload APK ==== ==== 4.1   ​Upload APK ====
- 
- 
  
 This function will help you push your new version App to users. You just need to modify VersionCode in AndroidManifest.xml and upload App APK to server. This function will help you push your new version App to users. You just need to modify VersionCode in AndroidManifest.xml and upload App APK to server.
- 
  
 ==== 4.2   Add Permission ==== ==== 4.2   Add Permission ====
- 
- 
  
 android.permission.WRITE_EXTERNAL_STORAGE android.permission.WRITE_EXTERNAL_STORAGE
- 
- 
 ==== 4.3   Basic Function ==== ==== 4.3   Basic Function ====
- 
- 
  
 Call UmsAgent.update(this) in onCreate() of App entry Activity when you want the APP to check that whether Web Server has a new version of the App automatically. Call UmsAgent.update(this) in onCreate() of App entry Activity when you want the APP to check that whether Web Server has a new version of the App automatically.
行 271: 行 246:
 UmsAgent.update(this);​ UmsAgent.update(this);​
 }</​code>​ }</​code>​
- 
- 
  
 In consideration of limitations of the user traffic, we now do automatic reminders under Wi-Fi intervention by default. In consideration of limitations of the user traffic, we now do automatic reminders under Wi-Fi intervention by default.
- 
  
 ==== 4.4   ​Mechanism Instructions ==== ==== 4.4   ​Mechanism Instructions ====
- 
- 
  
 When updating App every time, you just need to modify VersionCode and upload App APK to server. When updating App every time, you just need to modify VersionCode and upload App APK to server.
- 
  
 **UmsAgent.update()** will check that whether there is a new version App on server. It will notify user whether to ungrade SDK if there is a new App SDK. SDK wil upgrade after user choose to ungrade. (whether to ungrade according to version code) **UmsAgent.update()** will check that whether there is a new version App on server. It will notify user whether to ungrade SDK if there is a new App SDK. SDK wil upgrade after user choose to ungrade. (whether to ungrade according to version code)
- 
  
 ===== 5   Data Sending ===== ===== 5   Data Sending =====
 5.1   Model Explaination 5.1   Model Explaination
- 
- 
  
     * Start sending(recommended)     * Start sending(recommended)
- 
  
 App only sends a message to server when it starts. All messages produced during App will be sent to server on next time start. If the App starts without network, then the messages will be stored in local and App will try to send next time. App only sends a message to server when it starts. All messages produced during App will be sent to server on next time start. If the App starts without network, then the messages will be stored in local and App will try to send next time.
- 
- 
  
     * Real-time Sending     * Real-time Sending
- 
- 
 Once App produces a message, sending it to server immediately. Once App produces a message, sending it to server immediately.
- 
  
 5.2   Set sending model 5.2   Set sending model
- 
  
 Call UmsAgent.setDefaultReportPolicy(Context,​int) in entry Activity. Parameter int could be 0 or 1. Call UmsAgent.setDefaultReportPolicy(Context,​int) in entry Activity. Parameter int could be 0 or 1.
- 
  
 1 stands for Real-time sending and 0 stands for Start sending. 1 stands for Real-time sending and 0 stands for Start sending.
  
 ===== 6   ​Online Configuration ===== ===== 6   ​Online Configuration =====
- 
- 
  
 UmsAgent.updateOnlineConfig(Context) UmsAgent.updateOnlineConfig(Context)
行 322: 行 278:
  
 You can also read your custom parameters by using following API: You can also read your custom parameters by using following API:
- 
  
 UmsAgent.updateOnlineConfig(Context context,​String key) UmsAgent.updateOnlineConfig(Context context,​String key)
  
 **key:** the key which has been defined on the web . A empty string will be returned if the corresponding value is not read. **key:** the key which has been defined on the web . A empty string will be returned if the corresponding value is not read.
en/razor/android-developer-guide.txt · 最后更改: 2017/07/14 11:18 (外部编辑)