乱舞应该在服务和AsyncTasks使用吗? [英] Flurry should be used in Services and AsyncTasks?

查看:394
本文介绍了乱舞应该在服务和AsyncTasks使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用乱舞Analitcs 的在我的应用程序。 阅读SDK文档我从我的应用程序的每个活动做了以下code后:

I'm trying to use Flurry Analitcs in my app. After read a sdk document I did the following code in each activity from my application:

@Override
protected void onStart() {
    FlurryAgent.onStartSession(this, "xxxxxxxxxxxxxxxxx");
    super.onStart();
}

@Override
public void onStop() {
    super.onStop();
    FlurryAgent.onEndSession(this);
}

我的疑问是,我有很多的AsyncTask在我的应用程序的一些IntentServices,并在文件中,他们说:

My doubt is that I have many AsyncTask and some IntentServices in my app, and in the documents they say:

将调用FlurryAgent.onStartSession(背景下,字符串),它传递一个参考   一个Context对象(如活动或服务)

Insert a call to FlurryAgent.onStartSession(Context, String), passing it a reference to a Context object (such as an Activity or Service)

所以,我应该叫onStartSession在onHandleIntent方法?而且我应该在哪里呼吁onEndSession?在最后的过程,并在finally块? 而关于AsyncTasks,应该怎么实现它太,即使我通过我的任务,通过我的活动范围内?

So, should I call onStartSession in onHandleIntent method?? And where should I call on onEndSession? In the final process and in a finally block? And about AsyncTasks, should I implement it too even if I pass my activity context through my task?

推荐答案

在FlurryAgent存在为您的应用程序中的一个单实体。每当你调用onStartSession()你开始一个新的会话和呼叫onEndSession()将结束当前活动的会话。这是无论在哪里,你叫FlurryAgent线程的。

The FlurryAgent exists as a singleton entity within your application. Whenever you call onStartSession() you begin a new session and calling onEndSession() will end the currently active session. This is regardless of the thread where you call FlurryAgent.

你怎么想在你的应用程序中定义的会议主要是由你。对于大多数应用,会话被定义为时间段,当用户与应用程序进行交互。这就是为什么文档建议调用onStartSession()和onEndSession()在活动生命周期的功能,因此,本次会议将包括所有的用户交互。

How you want to define sessions in your application is largely up to you. For most applications, a session is defined as periods of time when the user interacts with the application. This is why the documentation suggests calling onStartSession() and onEndSession() in the Activity lifecycle functions so that the session will encompass all user interactions.

如果正在执行而一个活动正在显示没有必要调用onStartSession()再次,因为它将已经从封闭活动追踪一个AsyncTask的。如果你有一个运行独立活动是由你何时调用onStartSession()后台服务。

If an AsyncTask is being performed while an Activity is being shown there is no need to call onStartSession() again since it will already be tracked from the enclosing Activity. If you have a background service that runs independently of Activities it is up to you when to call onStartSession().

请注意,如果你有一个可以indenfinitely定期运行,你应该叫onEndSession(),这样的数据报道,由于数据是在会话开始和结束时只报服务。

Note that if you have a service that can run indenfinitely you should call onEndSession() periodically so that data is reported, since data is only reported when a session is started and ended.

这篇关于乱舞应该在服务和AsyncTasks使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆