1

現在、Samsung S7500、Galaxy Mexus、HTC explore の 3 つのデバイスをテストに使用しています。デバイスがアクティブな場合、3 つのデバイスすべてでプッシュ通知を受信して​​います。アイドル状態 (ロック/スリープ) の場合、3 つのデバイスすべてでプッシュ通知を受信して​​います。ただし、プッシュ メッセージが送信されたときにオフラインの場合、オンラインになったときに、ドキュメントに従ってすべての保留中の通知を受け取る必要があります。しかし、この場合、すべてのデバイスで通知を受け取っていません。特にGalaxy Nexusでは、アイドル状態の場合に受信する場合とそうでない場合があります。どこが間違っていますか?誰でも私を助けることができますか?

サード パーティ サーバー (.Net) から GCM サーバーに投稿された文字列 end: ここで、「i」は現在の時刻です。

String postdata= "collapse_key=score_update"+i+"&time_to_live=2419200&delay_while_idle=1&data.message=‌​"+ message + "&data.time=" + System.DateTime.Now.ToString()
                    + "&registration_id=" + deviceToken + "";

Wakelock を含むドキュメントに従って、必要なすべてのアクセス許可をマニフェストに記載しました。これは、GCMIntentService クラスでの通知用の私のコードです。

            int icon = R.drawable.notif;
        long when = System.currentTimeMillis();
            NotificationManager notificationManager =(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
        Notification notification = new Notification();
        Intent notificationIntent = new Intent(context, DemoActivity.class);
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent intent = PendingIntent.getActivity(context, (int) when,
                notificationIntent,0);
           RemoteViews contentView = new RemoteViews(getPackageName(),R.layout.notify);
        contentView.setImageViewResource(R.id.ImageViewpnotify, icon);
        contentView.setTextViewText(R.id.TextViewpnotify, message);
        notification.contentView = contentView;
        notification.contentIntent= intent;
        notification.icon = icon;   
        notification.flags |= Notification.FLAG_AUTO_CANCEL;       
            notification.defaults |= Notification.DEFAULT_SOUND;       
            notification.defaults |= Notification.DEFAULT_VIBRATE;      
        notification.ledARGB = 0xffff0000;
        notification.flags |= Notification.FLAG_SHOW_LIGHTS;
        notification.ledOnMS = 100; 
        notification.ledOffMS = 100;
        notificationManager.notify((int)when, notification);
4

1 に答える 1

0

あなたの質問に答えるのが遅いことはわかっていますが、同じ問題があり、次のリンクを使用して解決できました。

https://gist.github.com/mgartner/7092333

これは、サービスがアイドル状態になり、通知の受信を停止する一部のデバイスのバグです。解決策は、5 分ごとに強制的に再起動することです。また、次のリンクを使用して、gcmreceiver のカスタマイズに役立てることもできます。

http://code.google.com/p/gcm/source/browse/gcm-client/src/com/google/android/gcm/GCMBaseIntentService.java?r=8094cc6410b7dc2db452eb19cc9274fda1b2d6a2

于 2014-03-25T06:54:39.470 に答える