android -- 统计app 打开次数

2017-10-25  本文已影响275人  喜欢书的女孩
  1. 极光推送
  1. 使用步骤
buildscript {
    repositories {
        jcenter() //加入
    }  
}
allprojects {
    repositories {
        jcenter() //加入
    }
}
 defaultConfig {
        manifestPlaceholders = [
                JPUSH_APPKEY : "appkey", //JPush上注册的包名对应的appkey.
                JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
        ]
    }
}
dependencies {
    compile 'cn.jiguang.sdk:janalytics:1.1.1'
    compile 'cn.jiguang.sdk:jcore:1.1.2'
}

    <!-- Required  一些系统要求的权限,如访问网络等-->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <!-- Optional for location -->
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 用于开启 debug 版本的应用在6.0 系统上 层叠窗口权限 -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_TASKS" />

    <application
        <meta-data android:name="JPUSH_APPKEY" android:value="a855a345d085032caf4f984c"/>
        <meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
    </application>
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        JAnalyticsInterface.setDebugMode(true);     // 设置开启日志,发布时请关闭日志
        JAnalyticsInterface.init(this);  //初始化接口
    }
}
 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void onStart() {
        super.onStart();

    }

    @Override
    protected void onResume() {
        super.onResume();
        JAnalyticsInterface.onPageStart(getApplicationContext(),this.getClass().getCanonicalName());
    }


    @Override
    protected void onPause() {
        super.onPause();     
        JAnalyticsInterface.onPageEnd(getApplicationContext(),this.getClass().getCanonicalName());

    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
  1. 结果统计


    结果.png
上一篇下一篇

猜你喜欢

热点阅读