当前位置: 首页>>代码示例>>Java>>正文


Java GoogleCloudMessaging.MESSAGE_TYPE_DELETED属性代码示例

本文整理汇总了Java中com.google.android.gms.gcm.GoogleCloudMessaging.MESSAGE_TYPE_DELETED属性的典型用法代码示例。如果您正苦于以下问题:Java GoogleCloudMessaging.MESSAGE_TYPE_DELETED属性的具体用法?Java GoogleCloudMessaging.MESSAGE_TYPE_DELETED怎么用?Java GoogleCloudMessaging.MESSAGE_TYPE_DELETED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.android.gms.gcm.GoogleCloudMessaging的用法示例。


在下文中一共展示了GoogleCloudMessaging.MESSAGE_TYPE_DELETED属性的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_DELETED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。