日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Flurry 统计(国际版)

發布時間:2023/12/10 编程问答 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Flurry 统计(国际版) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Android-Flurry統計:
Flurry官方地址:
https://developer.yahoo.com/
Flurry登錄地址:
https://login.flurry.com/
前言:
Flurry是國外一家專門為移動應用提供數據統計和分析的公司。他們的數據統計分析SDK支持的平臺包括iPhone, iPad, Android, Windows Phone, Java ME和BlackBerry。使用Flurry服務的公司包括eBay、Yahoo、Hulu和Skype等超過11萬家公司,涉及的應用超過36萬個。

利用Flurry提供的分析平臺,我們可以很容易地自動統計出應用的使用情況,例如:

1、每天(每周或每月)登錄用戶數,應用使用次數
2、每天(每周或每月)新用戶數,活躍用戶數
3、用戶的所在地、年齡、性別的分布情況
等……..
個人推薦:
國內用友盟統計
國外就Flurry:其中的一個理由就是Flurry不會被墻!

集成文檔譯(最新版)

Flurry:集成地址:
https://developer.yahoo.com/flurry/docs/integrateflurry/android/
先決條件:Android API等級10及以上。

創建應用并獲取API_Key

創建應用地址:
https://y.flurry.com/admin/applications
創建步驟:如圖:

說明:App name:這里可以自己隨意填寫(和包名沒有關系);只要是自己明白就可以了。
其他步驟一直點下去就可以了。最終:
點擊:Ok,got it!
這個時候就申請Key成功了 copy一份API Key(AppKey) 便于后面程序中用到。

添加依賴庫

在App項目–>build.gradle中添加:

// In your main app's Gradle config file:repositories {jcenter() }dependencies {// Required for Flurry Analytics integration// Flurry Analytics集成所需的compile 'com.flurry.android:analytics:7.0.0@aar'// Optional - If you want to use the Ads SDK//可選 - 如果要使用Ads SDK :廣告SDKcompile 'com.flurry.android:ads:7.0.0@aar' }

重要:
強烈建議您使用Flurry SDK的AAR格式。現在不推薦使用jar。請更新為AAR,因為Flurry將在以后的版本中刪除jar。
注意:
如果要添加Flurry依賴項的AAR格式,則不需要修改AndroidManifest文件或ProGuard配置。

配置Mainfest.xml文件

以下是AndroidManifest.xml為Flurry Analytics和Flurry廣告配置的文件示例。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.flurry.sample"android:versionCode="1"android:versionName="1.0" ><!-- Required permissions - 必要的權限 --><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><application android:name=".MyApplication"android:allowBackup="true"android:icon="@mipmap/app_icon"android:label="@string/app_name"android:theme="@style/AppTheme" ><!-- Required Activities if using Flurry Advertising 使用Flurry廣告必要--><activity android:name="com.flurry.android.FlurryFullscreenTakeoverActivity"android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode| screenSize|smallestScreenSize"></activity></application></manifest>

代碼中初始化APPKey

官方原文:
Add the following calls to initialize the Flurry SDK by using the FlurryAgent.Builder to initialize the Flurry SDK with your project’s API key. If you are shipping an app, use the FlurryAgent Builder to init the SDK, passing it a reference to your Application Context and your project’s API key:
簡單來說就是在上下文中添加初始化操作:Application類中

public class MyApplication extends Application {@Overridepublic void onCreate() {super.onCreate();new FlurryAgent.Builder().withLogEnabled(true).build(this, FLURRY_API_KEY);} }

注意:6.0的Flurry版本的初始化 函數是 init(..);也是個人之前用的一個版本:如:

FlurryAgent.init(this, FLURRY_API_KEY);//flurry統計初始化

But:
It is safe to call the Builder more than once, provided that you use the same API key throughout the application. You may use any type of Context you wish. The following methods are now deprecated: setFlurryAgentListener(), setLogEnabled(), setLogLevel(), setContinueSessionMillis(), setCaptureUncaughtExceptions(), setPulseEnabled() and init().
意思就是說:現在新版本不推薦使用以下方法了:
setFlurryAgentListener(),setLogEnabled(),setLogLevel(),setContinueSessionMillis(),setCaptureUncaughtExceptions(),setPulseEnabled()和init()。

Activity代碼添加

官方原文:(可以不看—-)
If you are writing an app and the minimum target is Ice Cream Sandwich or above (minSdkVersion is set to API level 14 or greater), session handling is completely automatic and you may skip steps 1 and 2. If you are instrumenting another type of Context, such as a Service, or your minimum target is Gingerbread, proceed with steps 1 or 2.

If your app is targeting Gingerbread or Honeycomb(API 10 -13), follow these steps:

Insert a call to FlurryAgent.onStartSession(Context) in your Activity’s onStart() method passing it a reference to a Context object (such as an Activity or Service). Do not pass in the global Application context. If you are targeting Gingerbread, we recommend using the onStart method of each Activity in your application, and passing the Activity itself as the Context object. For services (or other Contexts), use the Service or the relevant Context as the Context object.

Insert a call to FlurryAgent.onEndSession(Context) in your Activity’s onStop() method. Do not pass in the global Application context. If you are targeting Gingerbread, we recommend using the onStop method of each Activity in your application. For services (or other Contexts), ensure that onStop is called in each instrumented Service. Make sure to match up a call to onEndSession for each call of onStartSession, passing in the same Context object that was used to call onStartSession.

As long as there is any Context that has called onStartSession but not onEndSession, the session will be continued. Also, if a new Context calls onStartSession within 10 seconds of the last Context calling onEndSession, then the session will be resumed, instead of a new session being created. Session length, usage frequency, events and errors will continue to be tracked as part of the same session. This ensures that as a user transitions from one Activity to another in your application that they will not have a separate session tracked for each Activity, but will have a single session that spans many activities. If you want to track Activity usage, we recommend using logEvent, described below.
個人認為就辦了一個事情就是 在Activity中添加操作Flurry的事件:
就是在所有Activity中:成對的onStart()和onStop()中分別添加:
onStart:

FlurryAgent.setCaptureUncaughtExceptions(true);//這個看個人需要FlurryAgent.onStartSession(this, FLURRY_API_KEY);

onStop:

FlurryAgent.onEndSession(this);

添加完成就是這種的了:

@Overrideprotected void onStart() {super.onStart();FlurryAgent.setCaptureUncaughtExceptions(true);//這個看個人需要FlurryAgent.onStartSession(this, FLURRY_API_KEY);}@Overrideprotected void onStop() {super.onStop();FlurryAgent.onEndSession(this);}

OK到這里基本就集成完成了;
就可以實現 Flurry的統計新增、日活等操作了。

擴展

個人配置Flurry使用:

說明:個人用的版本是:FlurryAnalytics-6.2.0的架包:

申請AppKey

申請AppKey–>獲取AppKey:這里就不說了

添加統計架包

基礎統計jar: FlurryAnalytics-6.2.0.jar
廣告jar(個人沒用):FlurryAds-6.2.0
下載[FlurryAnalytics-6.2.0的架包]
添加到項目:libs文件中–>選中右鍵–>Add As Library…

代碼配置

1:定義一個全局的靜態類TestConstant.java(是否用靜態類個人隨意):
把AppKey 定義在這個類里面:如

public static String flurryKey = "自己的AppKey";// flurry統計key

2:在全局類(TestApplication.java)中的OnCreate()中初始化 AppKey:
如:

FlurryAgent.setLogEnabled(false);//TJ:統計日志是否開啟FlurryAgent.init(this, TestConstant.flurryKey);//flurry統計初始化

3:Activity 中使用統計添加代碼:

添加代碼:@Overrideprotected void onStart() {super.onStart();FlurryAgent.setCaptureUncaughtExceptions(true);FlurryAgent.onStartSession(this, TestConstant.flurryKey);}@Overrideprotected void onStop() {super.onStop();FlurryAgent.onEndSession(this);}

添加權限

<!-- Required permissions - 必要的權限 --><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

混淆

將以下說明添加到您的proguard.cfg文件中:

# Required to preserve the Flurry SDK -keep class com.flurry.** { *; } -dontwarn com.flurry.** -keepattributes *Annotation*,EnclosingMethod,Signature -keepclasseswithmembers class * {public (android.content.Context, android.util.AttributeSet, int);}# Google Play Services library-keep class * extends java.util.ListResourceBundle {protected Object[ ][ ] getContents(); }-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {public static final *** NULL;}-keepnames @com.google.android.gms.common.annotation.KeepName class *-keepclassmembernames class * {@com.google.android.gms.common.annotation.KeepName *;}-keepnames class * implements android.os.Parcelable {public static final ** CREATOR;}

OK到這里基本就能實現 Flurry統計的 新增、日活 等統計了。
舉例子:新增/日活的查看方式如圖:

NEW DEVICES:就是對于日期對于的 新增
ACTIVE DEVICES/DAY:就是對于日期對于的 活躍設備
是不是很簡單。

說明:
1:Flurry和友盟一樣也是通過設備唯一ID判斷數據的。
2:Flurry統計一般是有延遲的;個人測試發現延遲最大可能有6-8個小時;
所以:個人一般看數據都是凌晨后看前一天的數據。


OK后續會持續完善學習內容:
A:flurry統計 : 個人認為國際上相對好用的統計,O(∩_∩)O哈哈~
B:友盟統計:國內比較強大且好用的統計。
C:極光推送: 主要推送功能比較完善簡單。
D:個推: 一個統計。
E:51.la: 針對IP(web頁面)統計的一個統計:添加前需要頁面支持。
F:CNZZ : 很早和友盟合并了;導致友盟叫:友盟+;不錯O(∩_∩)O哈哈~
等…

總結

以上是生活随笔為你收集整理的Flurry 统计(国际版)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。