本文整理匯總了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);
}