Commit a820d907c5c8f640f97ee07fc3b668a9e62f4880
1 parent
f55ebd182c
Exists in
master
add new event tracking
Showing 6 changed files with 16 additions and 7 deletions Inline Diff
TraceSDKSample/AndroidManifest.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
3 | package="com.mobithink.tracesdk.sample" | 3 | package="com.mobithink.tracesdk.sample" |
4 | android:versionCode="1" | 4 | android:versionCode="1" |
5 | android:versionName="1.0" > | 5 | android:versionName="1.0" > |
6 | 6 | ||
7 | <uses-sdk | 7 | <uses-sdk |
8 | android:minSdkVersion="8" | 8 | android:minSdkVersion="8" |
9 | android:targetSdkVersion="10" /> | 9 | android:targetSdkVersion="10" /> |
10 | <uses-permission android:name="android.permission.INTERNET"/> | 10 | <uses-permission android:name="android.permission.INTERNET"/> |
11 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> | 11 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> |
12 | <uses-permission android:name="android.permission.READ_PHONE_STATE"/> | 12 | <uses-permission android:name="android.permission.READ_PHONE_STATE"/> |
13 | <uses-permission android:name="android.permission.WRITE_SETTINGS" /> | ||
14 | <uses-permission android:name="android.permission.READ_SETTINGS" /> | ||
15 | <uses-permission android:name="android.permission.BLUETOOTH" /> | ||
13 | 16 | ||
14 | <application | 17 | <application |
15 | android:allowBackup="true" | 18 | android:allowBackup="true" |
16 | android:icon="@drawable/ic_launcher" | 19 | android:icon="@drawable/ic_launcher" |
17 | android:label="@string/app_name" | 20 | android:label="@string/app_name" |
18 | android:theme="@style/AppTheme" > | 21 | android:theme="@style/AppTheme" > |
19 | <activity | 22 | <activity |
20 | android:name="com.mobithink.tracesdk.sample.MainActivity" | 23 | android:name="com.mobithink.tracesdk.sample.MainActivity" |
21 | android:label="@string/app_name" > | 24 | android:label="@string/app_name" > |
22 | <intent-filter> | 25 | <intent-filter> |
23 | <action android:name="android.intent.action.MAIN" /> | 26 | <action android:name="android.intent.action.MAIN" /> |
24 | 27 | ||
25 | <category android:name="android.intent.category.LAUNCHER" /> | 28 | <category android:name="android.intent.category.LAUNCHER" /> |
26 | </intent-filter> | 29 | </intent-filter> |
27 | </activity> | 30 | </activity> |
28 | </application> | 31 | </application> |
29 | 32 | ||
30 | </manifest> | 33 | </manifest> |
31 | 34 |
TraceSDKSample/libs/TraceSDK1.0.0_proguard.jar
No preview for this file type
TraceSDKSample/libs/TraceSDK1.0_proguard..jar
No preview for this file type
TraceSDKSample/project.properties
1 | # This file is automatically generated by Android Tools. | 1 | # This file is automatically generated by Android Tools. |
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! | 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! |
3 | # | 3 | # |
4 | # This file must be checked in Version Control Systems. | 4 | # This file must be checked in Version Control Systems. |
5 | # | 5 | # |
6 | # To customize properties used by the Ant build system edit | 6 | # To customize properties used by the Ant build system edit |
7 | # "ant.properties", and override values to adapt the script to your | 7 | # "ant.properties", and override values to adapt the script to your |
8 | # project structure. | 8 | # project structure. |
9 | # | 9 | # |
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): |
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt |
12 | 12 | ||
13 | # Project target. | 13 | # Project target. |
14 | target=android-19 | 14 | target=android-19 |
15 | |||
16 | 15 |
TraceSDKSample/res/layout/activity_main.xml
1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
2 | android:id="@+id/container" | 2 | android:id="@+id/container" |
3 | android:layout_width="match_parent" | 3 | android:layout_width="match_parent" |
4 | android:layout_height="match_parent" | 4 | android:layout_height="match_parent" |
5 | android:gravity="center" | 5 | android:gravity="center" |
6 | android:orientation="vertical" > | 6 | android:orientation="vertical" > |
7 | 7 | ||
8 | <Button | 8 | <Button |
9 | android:id="@+id/send" | 9 | android:id="@+id/send" |
10 | android:layout_width="wrap_content" | 10 | android:layout_width="wrap_content" |
11 | android:layout_height="wrap_content" | 11 | android:layout_height="wrap_content" |
12 | android:text="Mark an event" /> | 12 | android:text="Mark an event" /> |
13 | <Button android:id="@+id/reg" | ||
14 | android:layout_width="wrap_content" | ||
15 | android:layout_height="wrap_content" | ||
16 | android:text="Register"/> | ||
13 | 17 | ||
14 | <Button | 18 | <Button |
15 | android:id="@+id/upgrade" | 19 | android:id="@+id/upgrade" |
16 | android:layout_width="wrap_content" | 20 | android:layout_width="wrap_content" |
17 | android:layout_height="wrap_content" | 21 | android:layout_height="wrap_content" |
18 | android:text="Level upgrade" /> | 22 | android:text="Level upgrade" /> |
19 | 23 | ||
20 | <Button | 24 | <Button |
21 | android:id="@+id/purchase" | 25 | android:id="@+id/purchase" |
22 | android:layout_width="wrap_content" | 26 | android:layout_width="wrap_content" |
23 | android:layout_height="wrap_content" | 27 | android:layout_height="wrap_content" |
24 | android:text="Purchase" /> | 28 | android:text="Purchase" /> |
25 | 29 | ||
26 | </LinearLayout> | 30 | </LinearLayout> |
TraceSDKSample/src/com/mobithink/tracesdk/sample/MainActivity.java
1 | package com.mobithink.tracesdk.sample; | 1 | package com.mobithink.tracesdk.sample; |
2 | 2 | ||
3 | import java.util.HashMap; | 3 | import java.util.HashMap; |
4 | import java.util.Map; | 4 | import java.util.Map; |
5 | 5 | ||
6 | import com.mobithink.tracesdk.TraceAgent; | 6 | import com.mobithink.tracesdk.TraceAgent; |
7 | 7 | ||
8 | import android.os.Bundle; | 8 | import android.os.Bundle; |
9 | import android.support.v4.app.FragmentActivity; | 9 | import android.support.v4.app.FragmentActivity; |
10 | import android.view.View; | 10 | import android.view.View; |
11 | import android.view.View.OnClickListener; | 11 | import android.view.View.OnClickListener; |
12 | import android.widget.Button; | 12 | import android.widget.Button; |
13 | 13 | ||
14 | public class MainActivity extends FragmentActivity { | 14 | public class MainActivity extends FragmentActivity { |
15 | 15 | ||
16 | @Override | 16 | @Override |
17 | protected void onCreate(Bundle savedInstanceState) { | 17 | protected void onCreate(Bundle savedInstanceState) { |
18 | super.onCreate(savedInstanceState); | 18 | super.onCreate(savedInstanceState); |
19 | setContentView(R.layout.activity_main); | 19 | setContentView(R.layout.activity_main); |
20 | TraceAgent.active(MainActivity.this, "5486"); | 20 | TraceAgent.active(MainActivity.this, "5486"); |
21 | Button btnEvent = (Button) findViewById(R.id.send); | 21 | Button btnEvent = (Button) findViewById(R.id.send); |
22 | Button btnUp = (Button) findViewById(R.id.upgrade); | 22 | Button btnUp = (Button) findViewById(R.id.upgrade); |
23 | Button btnPurchase = (Button) findViewById(R.id.purchase); | 23 | Button btnPurchase = (Button) findViewById(R.id.purchase); |
24 | Button btnReg = (Button) findViewById(R.id.reg); | ||
24 | btnEvent.setOnClickListener(listener); | 25 | btnEvent.setOnClickListener(listener); |
25 | btnUp.setOnClickListener(listener); | 26 | btnUp.setOnClickListener(listener); |
26 | btnPurchase.setOnClickListener(listener); | 27 | btnPurchase.setOnClickListener(listener); |
28 | btnReg.setOnClickListener(listener); | ||
27 | } | 29 | } |
28 | 30 | ||
29 | @Override | 31 | @Override |
30 | protected void onPause() { | 32 | protected void onPause() { |
31 | TraceAgent.onPause(this); | 33 | TraceAgent.onPause(this); |
32 | super.onPause(); | 34 | super.onPause(); |
33 | } | 35 | } |
34 | 36 | ||
35 | @Override | 37 | @Override |
36 | protected void onResume() { | 38 | protected void onResume() { |
37 | TraceAgent.onResume(this); | 39 | TraceAgent.onResume(this); |
38 | super.onResume(); | 40 | super.onResume(); |
39 | } | 41 | } |
40 | 42 | ||
41 | OnClickListener listener = new OnClickListener() { | 43 | OnClickListener listener = new OnClickListener() { |
42 | 44 | ||
43 | @Override | 45 | @Override |
44 | public void onClick(View v) { | 46 | public void onClick(View v) { |
47 | Boolean a; | ||
45 | switch (v.getId()) { | 48 | switch (v.getId()) { |
46 | case R.id.send: | 49 | case R.id.send: |
47 | TraceAgent.onEvent(getApplicationContext(), "one test event"); | 50 | TraceAgent.onEvent(getApplicationContext(), "test_event"); |
48 | break; | 51 | break; |
49 | case R.id.purchase: | 52 | case R.id.purchase: |
50 | Map<String, String> params = new HashMap<String, String>(); | 53 | TraceAgent.onPurchase(getApplicationContext(), "USD", 10.5f); |
51 | params.put("amount", "10.5"); | ||
52 | params.put("currency", "USD"); | ||
53 | TraceAgent.onEvent(getApplicationContext(), "purchase", params); | ||
54 | break; | 54 | break; |
55 | case R.id.upgrade: | 55 | case R.id.upgrade: |
56 | TraceAgent.onEvent(getApplicationContext(), "upgrade", "11"); | 56 | TraceAgent.onUpgrade(getApplicationContext(), "11"); |
57 | break; | ||
58 | case R.id.reg: | ||
59 | TraceAgent.onRegister(getApplicationContext()); | ||
57 | break; | 60 | break; |
58 | } | 61 | } |
59 | } | 62 | } |