Android 使用Google云消息传递可以避免thread.sleep()吗?

Android 使用Google云消息传递可以避免thread.sleep()吗?,android,google-cloud-messaging,Android,Google Cloud Messaging,谷歌提供的链接解释了如何在Android应用程序中实现谷歌云消息 特别是,在处理消息接收的服务中,在onHandleIntent方法中,本教程使用以下代码: else if (GoogleCloudMessaging. MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. for

谷歌提供的链接解释了如何在Android应用程序中实现谷歌云消息

特别是,在处理消息接收的服务中,在
onHandleIntent
方法中,本教程使用以下代码:

else if (GoogleCloudMessaging.
                MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            // This loop represents the service doing some work.
            for (int i=0; i<5; i++) {
                Log.i(TAG, "Working... " + (i+1)
                        + "/5 @ " + SystemClock.elapsedRealtime());
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                }
            }
            Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime());
            // Post notification of received message.
            sendNotification("Received: " + extras.toString());
            Log.i(TAG, "Received: " + extras.toString());
        }
else if(谷歌云信息)。
MESSAGE_TYPE_MESSAGE.equals(messageType)){
//此循环表示正在执行某些工作的服务。

对于(inti=0;i它之所以存在,是因为它上面的注释中所述的原因

此循环表示正在执行某些工作的服务。


这是一个示例代码,模拟了该部分正在进行的一些实际工作。

您是否阅读了循环顶部的注释?当然……您是否阅读了我的问题?因为此注释没有回答问题。它是为了“表示正在做一些工作的服务”.这项工作与本教程的内容不同。我确实阅读了评论,但遗憾的是我不得不提及它…我只是不明白这是否应该被我自己的代码所取代,或者云消息是否有必要发挥作用。