本文整理汇总了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);
}
示例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);
}