Example usage for java.util.concurrent CancellationException toString

List of usage examples for java.util.concurrent CancellationException toString

Introduction

In this page you can find the example usage for java.util.concurrent CancellationException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:com.hoangsong.zumechat.gcm.MyGcmListenerService.java

/**
 * Called when message is received./*from w  ww  .  j av a 2s  . com*/
 *
 * @param from SenderID of the sender.
 * @param data Data bundle containing message data as key/value pairs.
 *             For Set of keys use data.keySet().
 */
// [START receive_message]
@Override
public void onMessageReceived(String from, Bundle data) {

    // [START_EXCLUDE]
    /**
     * Production applications would usually process the message here.
     * Eg: - Syncing with server.
     *     - Store message in local database.
     *     - Update UI.
     */

    try {
        String message = data.getString("message");
        String sound = data.getString("sound");
        String vibrate = data.getString("vibrate");
        if (Constants.DEBUG_MODE) {
            Log.d(TAG, "data: " + data.toString());
            Log.d(TAG, "From: " + from);
            Log.d(TAG, "Message: " + message);
            Log.d(TAG, "sound: " + sound);
            Log.d(TAG, "vibrate: " + vibrate);
        }
        CustomNotification notification = new CustomNotification();
        notification.setMessage(message);
        notification.setSound(sound);
        notification.setVibrate(vibrate);
        sendNotification(notification);

    } catch (CancellationException e) {
        if (Constants.DEBUG_MODE) {
            Log.e(Constants.TAG,
                    MyGcmListenerService.class.getName() + " CancellationException: " + e.toString());
        }
    } /*catch (InterruptedException e) {
      if(Constants.DEBUG_MODE){
          Log.e(Constants.TAG, MyGcmListenerService.class.getName() + " InterruptedException: " + e.toString());
      }
      } catch (ExecutionException e) {
      if(Constants.DEBUG_MODE){
          Log.e(Constants.TAG, MyGcmListenerService.class.getName() + " ExecutionException: " + e.toString());
      }
      } */catch (Exception e) {
        if (Constants.DEBUG_MODE) {
            Log.e(Constants.TAG, MyGcmListenerService.class.getName() + " Exception: " + e.toString());
        }
    }

    /**
     * In some cases it may be useful to show a notification indicating to the user
     * that a message was received.
     */
    //sendNotification(message);
    // [END_EXCLUDE]
}