android flurry 教程,Flurry App Analytics for Android

4. Add calls to init, onStartSession and onEndSession¶

Follow these steps, adding these calls:

If you are shipping an app, insert a call to FlurryAgent.init(Context, String) in your Application class, passing it a reference to your application Context and your project’s API key:

Alternatively, you may call init() just before onStartSession(). It is safe to call init() more than once, provided that you use the same API key throughout the application. You may use any type of Context you wish.

Note

If you wish to make calls to logEvent(...) directly after a call to init, it is best to register the listener FlurryAgentListener.onStartSession() for when the session has started. This will allow you to capture events as soon as the session is ready.

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 3 and 4. If you are instrumenting another type of Context, such as a Service, or your minimum target is Gingerbread, proceed with steps 3 or 4.

Insert a call to FlurryAgent.onStartSession(Context) in the Activity’s onStart() method, passing it a reference to a Context object (such as an Activity or Service). If you are targeting Gingerbread, Flurry recommends using the onStart() method of each Activity in your app, 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. Do not pass in the global Application context.

Insert a call to FlurryAgent.onEndSession(Context) in the Activity’s onStop() method, when a session is complete. If you are targeting Gingerbread, we recommend using the onStop method of each Activity in your app. 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. Do not pass in the global Application context.

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 app 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, Flurry recommends using logEvent(), as described in the Custom Events section.

If you wish to change the window during which a session can be resumed, call FlurryAgent.setContinueSessionMillis(long milliseconds) before the call to FlurryAgent.init().

The Flurry SDK automatically transfers the data captured during the session once the SDK determines the session completed. In case the device is not connected, the data is saved on the device and transferred once the device is connected again.

The SDK manages the entire process. Currently, there is no way for the app to schedule the data transfer.

You’re done! That’s all you need to do to begin receiving basic metric data.

Following these steps provides you with access to the wide range of features listed below. In the Lexicon section of the documentation, you’ll find detailed descriptions of these features and terms.

Sessions

Active Users

New Users

Session Length

Frequency of Use

Page Views

Custom User Segments

Lifecycle Metrics

User Retention

Version Adoption

Cross-App Usage

Demographic Estimates

Time of Day Reporting

Geographic Usage

Language Metrics

Devices

Carriers

Firmware Versions

Now that you’ve completed the basic setup, you are ready to move on to custom events, which enable you to better understand user behavior through tracking Custom Events.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值