Android Studio Phase 15th-Friends Union Statistics integration

Source: Internet
Author: User

first, the address of the official website: Http://dev.umeng.com/analytics/android-doc/integration#2_5

Then note the code that is instantiated into application:

private void Setumenganalsys () {//Turn on debug mode on line to turn off Mobclickagent.setdebugmode (true);  When the SDK is statistical fragment, it needs to close the activity's own page stats,//and then re-integrate the page statistics code (including the activity that called Onresume and OnPause) on each page.  Mobclickagent.openactivitydurationtrack (FALSE);  Mobclickagent.setautolocation (TRUE);  Mobclickagent.setsessioncontinuemillis (1000); Mobclickagent.updateonlineconfig (this); }

Permissions and key configuration refer to official website documents should be no problem:

     added in Gradle dependency:

dependencies {
   compile  ' Com.umeng.analytics:analytics:latest.integration '}

allprojects {
     repositories {
            mavencentral ()      
    }
}

Manifest configuration mainly includes adding permissions, filling in the appkey and filling in the channel ID three parts, the code example is as follows:

<manifest......><uses-sdk android:minsdkversion= "4" ></uses-sdk><uses-permission  Android:name= "Android.permission.ACCESS_NETWORK_STATE" ></uses-permission><uses-permission  Android:name= "Android.permission.ACCESS_WIFI_STATE"  /><uses-permission android:name= " Android.permission.INTERNET "></uses-permission><uses-permission android:name=" Android.permission.READ_PHONE_STATE "></uses-permission><application ......>......<activity  ....../><meta-data android:value= "Your_app_key"  android:name= "UMENG_APPKEY" ></ Meta-data><meta-data android:value= "Channel id"  android:name= "UMENG_CHANNEL"/></ Application>    </manifest>

The last example illustrates:

1.mobclickagent.onevent (Context context, string eventid);context  refers to the current activityeventid  The event ID for the current statistic. Example: Count the number of "forwarding" events in a microblog application, then call Mobclickagent.onevent (Mcontext, "Forward") in the forwarded function; 2.mobclickagent.onevent (Context &NBSP;CONTEXT,&NBSP;STRING&NBSP;EVENTID,&NBSP;HASHMAP&NBSP;MAP);map  is the property and value (Key-value key-value pair) for the current event. Example: Count the number of "buy" events in an e-commerce application, and the type and quantity of goods purchased, then call:hashmap<string,string> map = new  in the purchased function Hashmap<string,string> (); Map.put ("type", "book"), Map.put ("Quantity", "3");  mobclickagent.onevent ( mcontext,  "Purchase",  map); 3.mobclickagent.oneventvalue (Context context, string id, &NBSP;MAP&LT;STRING,STRING&GT;&NBSP;M,&NBSP;INT&NBSP;DU) id   The event idmap   as the property and value of the current event du    The value of the current event is the numeric value of the current event, and the range of values is a signed integer between -2,147,483,648  to  +2,147,483,647 , that is, the int 32 type, if the data exceeds that range, can result in data loss, affecting the accuracy of data statistics. Example: Statistics music playback, including music type, author and duration, can be called after the end of the music playback: int duration = 12000; //developers need to calculate their own music playback duration map< String, string> map_value = new hashmap<string, string> ();  Map_value.put ("type"  ,  "popular"  ); Map_value.put ("Artist"  ,  "Jjlin"  )  mobclickagent.oneventvalue (this,  "Music" &NBSP;  map_value, duration);

Here's a place to watch if you want to count the category information like the GridView, such as this:

650) this.width=650; "title=" Fk]]k[ov$o)]lwla}3t~tgk.png "alt=" wkiom1gratjhubg2aafxuedvjky614.png "src="/http S1.51cto.com/wyfs02/m02/89/61/wkiom1gratjhubg2aafxuedvjky614.png "/>

Refer to the following method:

    keshitongji.java

 package com.kangxin.patient.module;import java.util.hashmap;public class keshitongji  { public static final hashmap<string, string> map = new  HashMap<String, String> ();  public static void addmap ()  {   Map.put ("6",  "neurology");//  Neuro-Medical   map.put ("5",  "neurosurgery");//  neurosurgery    map.put (", " ophthalmology ");//  ophthalmic   map.put (" ", " ent ");//  ent    map.put (", ", "stom atology");//  dental   map.put (", " head and  Neck surgery ");//  head and Neck Surgery   map.put (" x ", " Thoracic surgery ");//  thoracic Surgery    map.put (", " ("Cardiac surgery");//  cardiac surgery   map.put ("",  "Respiratory");//   Respiratory Medicine   map.put ("3",  "Cardiovascular internal medicine");//  cardiovascular Medicine    map.put (", " DigeStive internal medicine ");//  Digestive Medicine   map.put (" 8 ", " General surgery ");//  General Surgical   map.put (", " nephrology ");//  nephrology   map.put (",  "spine  Surgery ");//  Spine Surgery   map.put (",  "Joint branch");//  Bone and Joint Section   map.put ("28" ,  "Hand surgery");//  Hand Surgery   map.put ("All",  "Burns surgery");//  burns    map.put (", ", "Sports discipline");//  Sports Discipline   map.put ("the",  "gynaecology"); /  gynecological   map.put ("",  "obstetric");//  obstetric   map.put (", " Breast  Surgery ");//  breast Surgery   map.put (" to ", " son of internal ");//  Pediatrics    Map.put (", ", "son of surgery");//  surgery   map.put ("Notoginseng",  "oncology");//  Oncology   map.put (", " dermatology);//  Dermatology   map.put (", ");//   Endocrine Department   map.Put (", ");//  Rheumatology   map.put ("rheumatology",  "hematology");//  Hematology Department of Medicine    map.put (", " allergy branch);//  Allergy   map.put ("9",  "radiology ") Department ");//  Radiology Department   map.put (",  "Occupational medicine");//  occupational diseases    Map.put ("0",  "vascular medicine");//  Vascular Medicine   map.put (", " Palliative care  office ");//  Palliative Care Division   map.put (" the ", " geriatrics ");//  geriatric   map.put (" 51 ",   "orthopaedic");//  Plastic Surgery Department   map.put (", " pain ");//  Pain Division   map.put (" 4 ",   "Urology");//  Urology   map.put ("0",  "male");//  male  }}

     call method:

 keshitongji.addmap ();    set<string>  mapset = keshitongji.map.keyset ();     iterator<string> iterator  = mapset.iterator ();    while  (Iterator.hasnext ())  {      string key = iterator.next ();     if  ( Key.equals (Listitem.getid ()  +  ")")  {      mobclickagent.onevent ( Mcontext,        keshitongji.map.get (key));      }    } 

Summary: Most of the operations are direct ID corresponding to the friend of the background upload key, format:

Click1, click, 0;click2, register, 0;CLICK3, login, 0

Note:

     format:. txt or. csv; UTF-8 Encoding
     field: Event ID, event name, event type (1 for compute event, 0 for Count event). The
     fields are separated by commas, one row for each event.

    650) this.width=650; "title=" Shiningchen.png "alt=" Wkiom1grbjlzk7ymaacvpae2sly060.png " Src= "Http://s5.51cto.com/wyfs02/M00/89/61/wKiom1gRbjLzK7ymAACvpaE2sLY060.png"/>

To scan Our time ~

This article is from the "Liangxiao Technology Center" blog, please be sure to keep this source http://liangxiao.blog.51cto.com/3626612/1866217

Android Studio Phase 15th-Friends Union Statistics integration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.