當前位置: 首頁>>代碼示例>>Java>>正文


Java GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR屬性代碼示例

本文整理匯總了Java中com.google.android.gms.gcm.GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Java GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR屬性的具體用法?Java GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR怎麽用?Java GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在com.google.android.gms.gcm.GoogleCloudMessaging的用法示例。


在下文中一共展示了GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onHandleIntent

@Override
protected void onHandleIntent(Intent intent) {
    final Bundle extras = intent.getExtras();
    final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    final String messageType = gcm.getMessageType(intent);

    GcmBroadcastReceiver.completeWakefulIntent(intent);

    if (!extras.isEmpty()) {
        switch (messageType) {
            case GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE: {
                onReceivedMessage(extras);
                break;
            }
            case GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR: {
                onReceivedErrorMessage(extras);
                break;
            }
            case GoogleCloudMessaging.MESSAGE_TYPE_DELETED: {
                onReceivedDeletedMessage(extras);
                break;
            }
        }
    }

    GcmBroadcastReceiver.completeWakefulIntent(intent);
}
 
開發者ID:ipublishing-osp,項目名稱:esnavi,代碼行數:27,代碼來源:GcmIntentService.java

示例2: onHandleIntent

@Override
protected final void onHandleIntent(final Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    // The getMessageType() intent parameter must be the intent you received
    // in your BroadcastReceiver.
    String messageType = gcm.getMessageType(intent);

    if (!extras.isEmpty()) {  // has effect of unpacking Bundle
        /*
         * Filter messages based on message type. Since it is likely that
         * GCM will be extended in the future with new message types,
         * just ignore any message types you're not interested in, or that
         * you don't recognize.
         */
        switch (messageType) {
            case GoogleCloudMessaging.MESSAGE_TYPE_DELETED:
                sendNotification("Deleted messages on server: "
                        + extras.toString());
                // If it's a regular GCM message, do some work.
                break;
            case GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE:
                if (intent.getStringExtra("NotificationKind")
                        .equals("PriceCheckLowerPrices1")) {
                    final String message
                            = getUserMessageForPriceCheckLowerPricesNotif(
                            intent);

                    Handler h = new Handler(Looper.getMainLooper());
                    h.post(new Runnable() {
                        @Override
                        public void run() {
                            Toast toast = Toast
                                    .makeText(getApplicationContext(),
                                            message,
                                            Toast.LENGTH_LONG);
                            toast.show();
                        }
                    });
                }
                break;
            case GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR:
            default:
                sendNotification("Send error: " + extras.toString());
                break;
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}
 
開發者ID:googlearchive,項目名稱:MobileShoppingAssistant-sample,代碼行數:50,代碼來源:GcmIntentService.java


注:本文中的com.google.android.gms.gcm.GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。