Android GCM IntentService 循环 "doing some work"?

标签 android google-cloud-messaging

我在 Android 应用程序中使用 Google Cloud Messaging,我想知道在收到 GCM 消息并在处理之前,IntentService 中这部分代码的用途是什么:

// This loop represents the service doing some work.
for (int i = 0; i < 5; i++) {
   if (D) Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime());
   try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
    }
}

对此有什么想法吗? 谢谢!

最佳答案

我不知道您从哪里获得代码,但看起来它除了说明 IntentService 可能执行一些需要大量时间的处理之外没有任何目的。因此就有了循环和 Thread.sleep。

关于Android GCM IntentService 循环 "doing some work"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25947614/

相关文章:

安卓异步任务和

android - 无法接收 Android GCM 中服务器发送的消息

Android GCM 配对服务器和客户端?

android - 如何在这个特定的 Android 用例中实现 MQTT?

java - 广播 Intent 已取消。安卓系统

java.lang.RuntimeException : Unable to instantiate application com. chiaramail.chiaramailforandroid.K9

java - 如何将2个不同的项目放入一个APK中

android - 变量点需要是final

java - GCM 不会在登录时向离线用户发送推送通知...不知道我错过了什么?

android - 将数据推送到应用程序