我在 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/