简体   繁体   English

GcmListenerService onMessageReceived允许运行时

[英]GcmListenerService onMessageReceived allowed runtime

The GcmListenerService handles wakelock for us. GcmListenerService为我们处理唤醒锁。 The onMessageReceived method runs in a thread pool (not on the main UI thread) so it seems as if the intention was to allow long running tasks to be executed on this method. onMessageReceived方法在线程池中运行(不在主UI线程上),因此似乎意图允许在此方法上执行长时间运行的任务。

My question is whether there is some kind of a runtime limit of this method when GCM is received. 我的问题是,当收到GCM时,此方法是否存在某种运行时限制。 Basically I would want to download a few images during the run of this method and then post a notification to the user, and be certain that the device does not go to sleep and finishes its execution. 基本上我想在此方法运行期间下载一些图像,然后向用户发布通知,并确保设备不会进入休眠状态并完成其执行。

As far as I understand, the fact that GcmReceiver and GcmListenerService take care of a wakeup lock for us, allows us to do the heavy tasks on this method and be certain that it finishes. 据我所知,GcmReceiver和GcmListenerService为我们处理唤醒锁的事实允许我们对此方法执行繁重的任务并确保它完成。 Is this true? 这是真的?

Hope that not is too late for the answer but about the question, yes you can do long running process(in your case I/O) as the GcmListenerService class extends android.app.Service and you can still notify the user that you are processing something in background and show the process of it via a Notification. 希望答案不是太迟,但问题是,是的,你可以做长时间运行的过程(在你的情况下是I / O),因为GcmListenerService类扩展了android.app.Service,你仍然可以通知用户你正在处理在背景中的东西,并通过通知显示它的过程。

Android Documentation - Displaying a fixed-duration progress indicator Android文档 - 显示固定持续时间进度指示器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM