用户工具

站点工具


差别

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

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
后一修订版
前一修订版
en:razor:android-developer-guide [2015/03/18 15:37]
cobub [3.1 Error Report]
en:razor:android-developer-guide [2017/07/14 11:18] (当前版本)
行 1: 行 1:
 +~~Title:​Cobub Razor Android Developer Guide - Mobile Apps Marketing Platform of Open Source - Mobile Analytics & Mobile Push Notification Solutions - Cobub Mobile Developer Center~~
 +{{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}}
 +
 +
 ====== Cobub Razor Android Developer Guide ====== ====== Cobub Razor Android Developer Guide ======
- 
-  - [[#​Overview|Overview]] 
-  - [[#Basic Setup Guide|Basic Setup Guide]] 
-  - [[#Advanced Setup Guide|Advanced Setup Guide]] 
-  - [[#App Update|App Update]] 
-  - [[#Data Sending|Data Sending]] 
-  - [[#Online Configuration|Online Configuration]] 
  
 ===== 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.
行 24: 行 20:
  
  
-Cobub Razor  -  [[en:razor:|The Open Source ​ Mobile Analytics]]+Cobub Razor  -  [[en:start|The Open Source ​ Mobile Analytics]]
  
 ===== 2   Basic Setup Guide ===== ===== 2   Basic Setup Guide =====
行 37: 行 33:
  
  
-=== 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 ===
行 110: 行 107:
 * 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(){
行 126: 行 122:
  
 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(){
行 135: 行 128:
 }</​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){
行 150: 行 140:
     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() {
  
行 169: 行 157:
  
 === 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.
行 184: 行 169:
     * 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 =====
行 204: 行 188:
 For the latter,​developers need to call UmsAgent.onError(Context,​String)and pass error info catched by their own to the second parameter. You can check that the log has been sent to the error analytics data statistics reports of my product. For the latter,​developers need to call UmsAgent.onError(Context,​String)and pass error info catched by their own to the second parameter. You can check that the log has been sent to the error analytics data statistics reports of my product.
  
 +==== 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:
 +
 +
 +UmsAgent.onEvent(Context context,​String event_id);
 +
 +//context: the reference of current context
 +
 +event_id: the ID of current statistics event, could not have spaces.//
 +
 +Invoke this API will send event info to the server and generate the event report on the server which analyzes sending times and changing trends corresponding to event_id, such as AD clicks, message numbers and so on. For example, to monitor AD clicks of App in MainActivtiy. Event ID is “ ad_click“. Once AD is clicked, you need call
 +
 +
 +UmsAgent.onEvent(MainActivity.this,​“ad_click“)
 +
 +in App to notify server that an AD click event  has occurred.
 +
 +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:
 +
 +UmsAgent.onEvent(Context context,​String event_id,​int acc)
 +UmsAgent.onEvent(Context context,​String event_id,​String label,int acc)
 +
 +**acc :** triggered times of corresponding event. In addition to the statistics of the number of events, here we  can save and statistics the value of the label according to event_id.The overloaded methods are as follows:
 +
 +
 +UmsAgent.onEvent(Context context,​String event_id,​String label,​double value)
 +
 +For example, event_id represents an “ order “ event, then the label can be marked as an " order number ", and the value represents the value of  the" order number ".
 +
 +
 +==== 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>
 +UmsAgent.setDebugEnabled(true);​
 +UmsAgent.setDebugLevel(UmsAgent.LogLevel);​
 +</​code> ​
 +LogLevel has five levels:​Info,​ Debug, Warn, Error, Verbose.
 +
 +===== 4   App Update =====
 +==== 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.
 +
 +==== 4.2   Add Permission ====
 +
 +android.permission.WRITE_EXTERNAL_STORAGE
 +==== 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.
 +
 +<​code>​public void onCreate(Bundle savedInstanceState) {
 +super.onCreate(savedInstanceState);​
 +setContentView(R.layout.activity_main);​
 +UmsAgent.update(this);​
 +}</​code>​
 +
 +In consideration of limitations of the user traffic, we now do automatic reminders under Wi-Fi intervention by default.
 +
 +==== 4.4   ​Mechanism Instructions ====
 +
 +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)
 +
 +===== 5   Data Sending =====
 +5.1   Model Explaination
 +
 +    * 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.
 +
 +    * Real-time Sending
 +Once App produces a message, sending it to server immediately.
 +
 +5.2   Set sending model
 +
 +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.
 +
 +===== 6   ​Online Configuration =====
 +
 +UmsAgent.updateOnlineConfig(Context)
 +
 +Invoke this API in **onCreate()** method of App's entey Activity and SDK will get your online configuration on the server and store this info in local.
 +
 +You can also read your custom parameters by using following API:
 +
 +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.
en/razor/android-developer-guide.1426664223.txt.gz · 最后更改: 2017/07/14 11:12 (外部编辑)