In the past two years, we have been conducting wireless tests and will continue to do wireless tests. However, we have not carefully understood the code layer for time reasons. Recently, I have made some app development by myself. I decided that if I want to do a good job in mobile testing, it is necessary to have a certain degree of app development experience, because only such a lot of things can be truly understood. On the other hand, this is also interesting. At present, some of the things we are trying are still relatively basic and we are ready to continue.
I also want to sort out the practices, take notes, and give some reference to others. When I encounter many problems, I also find answers from Google's experts, which helps a lot. Currently, more attention is paid to android, And the ios part continues.
Basically, any practical app can't do without tracking statistics. Otherwise, it will be a bit dark and difficult to make operations and decisions. In order to further understand this part, in addition to looking at the existing product practices (the Internal Platform of the company), I also want to write it on my own to deepen my understanding, so I chose umeng platform, which is widely used in the industry.
There are many statistical dimensions, but the most basic new users and the number of start times. This may involve changing the lifecycle and status of the Android activity. For better understanding, I made a simple code attempt.
Protectedvoid onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. activity_main );
Log. e (TAG, "enter onCreate ");
}
Protectedvoid onStart (){
Super. onStart ();
Log. e (TAG, "onStart ");
}
@ Override
Protectedvoid onResume (){
Super. onResume ();
Log. e (TAG, "onResume ");
}
@ Override
Protectedvoid onPause (){
Super. onPause ();
Log. e (TAG, "onPause ");
}
Then I did some experiments:
1. trigger the application main activity in three states for the first time: onCreate, onStart, and onResume.
2. Press the home Key to switch the application to the background and trigger onPause and onStop
3. Press the home Key, locate the application, switch back to the foreground, and trigger onStart and onResume.
Later I checked umeng's sample code and found that it was also based on this to count active users. Now, let's record the process of accessing umeng statistics.
First, you need to add permissions and some configuration in AndroidManifest. xml, mainly the appkey. This can be obtained after you have registered an account on the umeng website, and the Channel ID is defined by yourself.
......
Then add the corresponding code MobclickAgent class to the activity.
Import com. umeng. analytics. MobclickAgent;
Protectedvoid onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
MobclickAgent. updateOnlineConfig (this );
}
Protectedvoid onResume (){
Super. onResume ();
Log. e (TAG, "onResume ");
MobclickAgent. onResume (mContext );
}
Protectedvoid onPause (){
Super. onPause ();
Log. e (TAG, "onPause ");
MobclickAgent. onPause (mContext );
}
Add the jar package of umeng to the project.
However, after completing this step in Eclipse, I still encountered an error. When the MobclickAgent statement is executed, it becomes abnormal, as shown below. The official document only mentions the above steps.
The solution is to put the jar package of umeng under the libs directory of the project.
Next, the App runs and the data will be displayed in a few minutes.
The number of start times is measured by onResume (). Therefore, you need to pay attention to the details to see if adjustments are required.
We can see that the channel result is previously configured in AndroidManifest. xml.
Some information about the device cannot be viewed on the current day. It is more accurate to view the results on the next day.
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20140501/2014050108594934.jpg" alt = "\">
In addition, the custom Event is also tested. In my demo app, there are two parts to access the HTTP interface: Apache HttpClient and Android HttpClient. I want to count the number of calls and response time.
The corresponding code is embedded before and after the call.
MobclickAgent. onEventBegin (this, "Android_http_visit ");
MobclickAgent. onEventEnd (this, "Android_http_visit ");
In general, the basic statistics function is good, and development is also very convenient, much more convenient than previously imagined. However, considering the data analysis of self-developed BI tools used by our actual products and the large scale actual use cases with our friends, some application-layer functions are not particularly adequate. For example, the detailed user access path.
The following describes some basic models. However, if you want to analyze products and operations very carefully, you still need to do some work by yourself.
The funnel model, etc. Because the demo app is too simple to be further understood. In this way, you will find it easier to understand and read the operation data of the actual product.