List of usage examples for android.os Bundle isEmpty
public boolean isEmpty()
From source file:org.anhonesteffort.flock.ManageSubscriptionActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.simple_fragment_activity); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setTitle(R.string.title_manage_subscription); if (savedInstanceState != null && !savedInstanceState.isEmpty()) { if (!DavAccount.build(savedInstanceState.getBundle(KEY_DAV_ACCOUNT_BUNDLE)).isPresent()) { Log.e(TAG, "where did my dav account bundle go?! :("); finish();//from w w w .jav a 2 s .c o m return; } davAccount = DavAccount.build(savedInstanceState.getBundle(KEY_DAV_ACCOUNT_BUNDLE)).get(); currentFragment = savedInstanceState.getInt(KEY_CURRENT_FRAGMENT, -1); activityRequestCode = Optional.fromNullable(savedInstanceState.getInt(KEY_REQUEST_CODE)); activityResultCode = Optional.fromNullable(savedInstanceState.getInt(KEY_RESULT_CODE)); activityResultData = Optional.fromNullable((Intent) savedInstanceState.getParcelable(KEY_RESULT_DATA)); } else if (getIntent().getExtras() != null) { if (!DavAccount.build(getIntent().getExtras().getBundle(KEY_DAV_ACCOUNT_BUNDLE)).isPresent()) { Log.e(TAG, "where did my dav account bundle go?! :("); finish(); return; } davAccount = DavAccount.build(getIntent().getExtras().getBundle(KEY_DAV_ACCOUNT_BUNDLE)).get(); currentFragment = getIntent().getExtras().getInt(KEY_CURRENT_FRAGMENT, -1); activityRequestCode = Optional.fromNullable(getIntent().getExtras().getInt(KEY_REQUEST_CODE)); activityResultCode = Optional.fromNullable(getIntent().getExtras().getInt(KEY_RESULT_CODE)); activityResultData = Optional .fromNullable((Intent) getIntent().getExtras().getParcelable(KEY_RESULT_DATA)); } Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.setPackage("com.android.vending"); bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.firebase.ui.auth.ui.phone.PhoneVerificationActivity.java
@Override protected void onCreate(final Bundle savedInstance) { super.onCreate(savedInstance); setContentView(R.layout.activity_register_phone); mSaveSmartLock = mActivityHelper.getSaveSmartLockInstance(); mHandler = new Handler(); mVerificationState = VerificationState.VERIFICATION_NOT_STARTED; if (savedInstance != null && !savedInstance.isEmpty()) { mPhoneNumber = savedInstance.getString(KEY_VERIFICATION_PHONE); if (savedInstance.getSerializable(KEY_STATE) != null) { mVerificationState = (VerificationState) savedInstance.getSerializable(KEY_STATE); }//w w w. ja v a 2 s . com return; } String phone = getIntent().getExtras().getString(ExtraConstants.EXTRA_PHONE); VerifyPhoneNumberFragment fragment = VerifyPhoneNumberFragment.newInstance(mActivityHelper.getFlowParams(), phone); getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_verify_phone, fragment, VerifyPhoneNumberFragment.TAG) .disallowAddToBackStack().commit(); }
From source file:com.meiste.greg.ptw.gcm.GcmIntentService.java
@Override protected void onHandleIntent(final Intent intent) { final Bundle extras = intent.getExtras(); final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); final String messageType = gcm.getMessageType(intent); synchronized (mSync) { if (mContainer == null) { try { mSync.wait();//w ww . j ava 2 s . c o m } catch (final InterruptedException e) { } } } if (!extras.isEmpty()) { /* * 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 * not recognized. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Util.log("GCM send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Util.log("GCM deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if (intent.hasExtra(MSG_KEY)) { final String message = intent.getStringExtra(MSG_KEY); Util.log("Received " + message + " message from GCM"); if (MSG_KEY_SYNC.equals(message)) { getFromServer("schedule", scheduleListener, false); getFromServer("standings", standingsListener, true); } else if (MSG_KEY_HISTORY.equals(message)) { getFromServer("history", historyListener, true); } else if (MSG_KEY_RULES.equals(message)) { getFromServer("rule_book", rulesListener, false); } else { Util.log("Message type unknown. Ignoring..."); } } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.brq.wallet.lt.notification.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); try {//from w w w. ja v a2s . c om if (extras == null) { Log.i(TAG, "empty message received, ignoring"); return; } 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 unparcelling 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. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { Log.i(TAG, "SEND ERROR: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.i(TAG, "DELETED: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.i(TAG, "Received: " + extras.toString()); if (LtApi.TRADE_ACTIVITY_NOTIFICATION_KEY.equals(extras.getString("collapse_key"))) { handleTradeActivityNotification(extras); } else if (LtApi.AD_ACTIVITY_NOTIFICATION_KEY.equals(extras.getString("collapse_key"))) { handleAdActivityNotification(extras); } } } } finally { // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); } }
From source file:com.app.milesoft.facebook.Util.java
/** * Connect to an HTTP URL and return the response as a string. * * Note that the HTTP method override is used on non-GET requests. (i.e. * requests are made as "POST" with method specified in the body). * * @param url - the resource to open: must be a welformed URL * @param method - the HTTP method to use ("GET", "POST", etc.) * @param params - the query parameter for the URL (e.g. access_token=foo) * @return the URL contents as a String/* ww w.j a va 2 s .com*/ * @throws MalformedURLException - if the URL format is invalid * @throws IOException - if a network problem occurs */ public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os; if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Log.d("Facebook-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } } // use method override if (!params.containsKey("method")) { params.putString("method", method); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(params.getString("access_token")); params.putString("access_token", decoded_token); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); //conn.setRequestProperty("application/json","multipart/form-data;boundary="+strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); System.out.println("step 1"); conn.connect(); System.out.println("step 2"); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } return response; }
From source file:com.abbiya.broadr.gcm.GcmIntentService.java
@Override protected void onHandleIntent(Intent intent) { JobManager jobManager = BroadrApp.getInstance().getJobManager(); 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 unparcelling Bundle /*/*from www . j av a 2 s . c o m*/ * 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. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //retry sending String messageId = (String) extras.get("google.message_id"); String uuid = null; Integer msgType = null; if (messageId != null) { if (messageId.startsWith(Constants.MESSAGE_PREFIX)) { uuid = messageId.substring(Constants.MESSAGE_PREFIX.length(), messageId.length()); msgType = Constants.MESSAGE; } else if (messageId.startsWith(Constants.COMMENT_PREFIX)) { uuid = messageId.substring(Constants.COMMENT_PREFIX.length(), messageId.length()); msgType = Constants.COMMENT; } else if (messageId.startsWith(Constants.GCM_REGISTRATION)) { String email = BroadrApp.getSharedPreferences().getString(Constants.USER_EMAIL, ""); jobManager.addJobInBackground( new SendRegistrationMessageJob(email, UUID.randomUUID().toString())); } else if (messageId != null && messageId.startsWith(Constants.LOCATION_PREFIX)) { String geoHash = LocationUtils.getGeoHash(); GeoHash from = GeoHash.fromGeohashString(geoHash); WGS84Point point = from.getPoint(); Double startLatitude = point.getLatitude(); Double startLongitude = point.getLongitude(); SharedPreferences sharedPreferences = BroadrApp.getSharedPreferences(); String address = sharedPreferences.getString(Constants.LAST_KNOWN_ADDRESS, ""); jobManager.addJobInBackground(new SendLocationJob(String.valueOf(startLatitude), String.valueOf(startLongitude), address, UUID.randomUUID().toString())); } } if (uuid != null) { if (msgType == Constants.MESSAGE) { MessageRepo messageRepo = BroadrApp.getMessageRepo(); Message message = messageRepo.getMessage(uuid); if (message != null) { jobManager.addJobInBackground( new SendMessageJob(message.getId(), message.getContent(), message.getUuid())); } } else if (msgType == Constants.COMMENT) { CommentRepo commentRepo = BroadrApp.getCommentRepo(); Comment comment = commentRepo.getComment(uuid); if (comment != null) { jobManager.addJobInBackground( new SendCommentJob(comment.getId(), comment.getContent(), comment.getUuid())); } } } else { //sendNotification("Send error: " + extras.toString()); } } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), NOTIFICATION_ID); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { //parse the message and do db operations post the event //Post notification of received message. String receivedMessageType = extras.getString("t"); String messageId = null; MessageRepo messageRepo = BroadrApp.getMessageRepo(); CommentRepo commentRepo = BroadrApp.getCommentRepo(); Message message = null; Comment comment = null; if (null != extras.get("m_id")) { messageId = String.valueOf(extras.get("m_id")); } //check the message id prefix and find the comment or message if (messageId != null && messageId.startsWith(Constants.MESSAGE_PREFIX)) { messageId = messageId.substring(Constants.MESSAGE_PREFIX.length()); message = messageRepo.getMessage(messageId); } else if (messageId != null && messageId.startsWith(Constants.COMMENT_PREFIX)) { messageId = messageId.substring(Constants.COMMENT_PREFIX.length()); comment = commentRepo.getComment(messageId); } else if (messageId != null && messageId.startsWith(Constants.GCM_REGISTRATION)) { EventBus.getDefault().post(new SentRegistrationMessageEvent()); } else if (messageId != null && messageId.startsWith(Constants.LOCATION_PREFIX)) { EventBus.getDefault().post(new SentLocationEvent()); } if (extras.get("o") != null) { sendNotification(String.valueOf(extras.get("o")), 2); } if (message == null) { int type = 0; if (receivedMessageType != null) { switch (receivedMessageType.charAt(0)) { case 'r': type = 0; break; case 'l': type = 1; break; case 'm': type = 2; //received from gcm by others String content = String.valueOf(extras.get("c")); String geoHash = String.valueOf(extras.get("l")); String uuid = String.valueOf(extras.get("s_id")); message = messageRepo.getMessage(uuid); if (message == null) { message = new Message(content, new Date(), geoHash); message.setType(Constants.MESSAGE); message.setUpdatedAt(new Date()); message.setStatus(Constants.RECEIVED_GCM); message.setUuid(uuid); Board currentBoard = (Board) AppSingleton.getObj(Constants.CURRENT_BOARD_OBJ); if (currentBoard == null) { String board = BroadrApp.getSharedPreferences().getString(Constants.LAST_BOARD, null); if (board != null && board.length() >= 4) { currentBoard = BroadrApp.getBoardRepo().getBoard(board.substring(0, 4)); } } if (message.getHappenedAt().getTime() > new Date().getTime()) { message.setHappenedAt(new Date()); } message.setBoard(currentBoard); messageRepo.insertOrReplace(message); EventBus.getDefault().post(new SavedReceivedMessagesEvent()); EventBus.getDefault().post(new ReceivedGCMMessageEvent(message)); long when = Long.valueOf(BroadrApp.getSettingsPreferences() .getString(SettingsActivity.NOTIF_PERIOD, "1")).longValue(); if (when == 1) { checkNumberOfReceivedMessagesTillNowAndNotify(false); } } break; case 'c': type = 3; break; case 'a': type = 5; break; default: type = 0; break; } if (receivedMessageType.equals("lk")) { type = 4; } } } else { //this guy's message message.setUpdatedAt(new Date()); message.setStatus(Constants.DELIVERED); messageRepo.updateMessage(message); //message sent event EventBus.getDefault().post(new DeliveredRavenEvent(message)); mNotificationManager.cancel(StringUtilities.safeLongToInt(message.getId())); } if (comment != null) { comment.setHappenedAt(new Date()); comment.setUpdatedAt(new Date()); comment.setStatus(Constants.DELIVERED); commentRepo.updateComment(comment); //comment sent event EventBus.getDefault().post(new CommentDeliveredEvent(comment)); } } else { Log.d(Constants.APPTAG, messageType); //sendNotification(messageType); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.ble.facebook.Util.java
public static String posttowall(String url, String method, Bundle params, String Accesstoken) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os;//ww w . ja v a 2s . co m if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Log.d("Facebook-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } } // use method override if (!params.containsKey("method")) { params.putByteArray("method", method.getBytes()); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(Accesstoken); params.putByteArray("access_token", decoded_token.getBytes()); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); Log.d("OutputStreamedData", ("--" + strBoundary + endLine) + (encodePostBody(params, strBoundary)) + (endLine + "--" + strBoundary + endLine)); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } return response; }
From source file:com.sentaroh.android.BluetoothWidget.Log.LogFileListDialogFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (DEBUG_ENABLE) Log.v(APPLICATION_TAG, "onSaveInstanceState"); if (outState.isEmpty()) { outState.putBoolean("WORKAROUND_FOR_BUG_19917_KEY", true); }//from w ww. j a v a 2 s.com saveViewContents(); }
From source file:com.firescar96.nom.GCMIntentService.java
@Override protected void onHandleIntent(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()) /*//w ww. ja v a2 s . c om * 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. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) Log.i(Consts.TAG, "onHandleIntent: message error"); else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) Log.i(Consts.TAG, "onHandleIntent: message deleted"); // If it's a regular GCM message, do some work. else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message. System.out.println("Received: " + extras.toString()); if (context == null) { System.out.println("null conxtext"); /*Intent needIntent = new Intent(this, MainActivity.class); needIntent.putExtra("purpose", "update"); needIntent.putExtra("mate", (String)extras.get("mate")); needIntent.putExtra("event", (String)extras.get("event")); needIntent.putExtra("chat", (String)extras.get("chat")); needIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(needIntent);*/ System.out.println(getFilesDir().getAbsolutePath()); MainActivity.initAppData(getFilesDir().getAbsolutePath()); } try { if (extras.get("mate") != null) { //context.appData.getJSONArray("mates").put(extras.get("mate")); } if (extras.get("event") != null) { JSONObject eveData = new JSONObject("{\"event\":" + extras.get("event") + "}") .getJSONObject("event"); JSONArray eve = MainActivity.appData.getJSONArray("events"); for (int i = 0; i < eve.length(); i++) { System.out.println(eveData.getString("hash")); System.out.println(eve.getJSONObject(i).getString("hash")); if (eveData.getString("hash").equals(eve.getJSONObject(i).getString("hash"))) return; } eveData.accumulate("member", false); System.out.println(eveData.getLong("date")); System.out.println(Calendar.getInstance().getTimeInMillis()); if (eveData.getLong("date") < Calendar.getInstance().getTimeInMillis()) return; eve.put(eveData); Message msg = new Message(); Bundle data = new Bundle(); data.putString("type", "event." + eveData.getString("privacy")); data.putString("host", eveData.getString("host")); data.putString("date", eveData.getString("date")); msg.setData(data); contextHandler.sendMessage(msg); } if (extras.get("chat") != null) { JSONObject chatData = new JSONObject("{\"chat\":" + extras.get("chat") + "}") .getJSONObject("chat"); JSONArray eve = MainActivity.appData.getJSONArray("events"); for (int i = 0; i < eve.length(); i++) if (chatData.getString("hash").equals(eve.getJSONObject(i).getString("hash"))) { JSONObject msgSon = new JSONObject(); msgSon.accumulate("author", chatData.getString("author")); msgSon.accumulate("message", chatData.getString("message")); eve.getJSONObject(i).getJSONArray("chat").put(msgSon); Message msg = new Message(); Bundle data = new Bundle(); data.putString("type", "chat"); data.putString("author", chatData.getString("author")); data.putString("message", chatData.getString("message")); data.putBoolean("member", eve.getJSONObject(i).getBoolean("member")); data.putString("hash", chatData.getString("hash")); msg.setData(data); contextHandler.sendMessage(msg); return; } } MainActivity.closeAppData(getFilesDir().getAbsolutePath()); } catch (JSONException e1) { e1.printStackTrace(); } } // Release the wake lock provided by the WakefulBroadcastReceiver. MainBroadcastReceiver.completeWakefulIntent(intent); }
From source file:br.com.imovelhunter.imovelhunterwebmobile.GcmIntentService.java
@Override protected void onHandleIntent(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 (SessionUtilJson.getInstance(getApplicationContext()) .containsName(ParametrosSessaoJson.USUARIO_LOGADO)) { usuarioLogado = (Usuario) SessionUtilJson.getInstance(getApplicationContext()) .getJsonObject(ParametrosSessaoJson.USUARIO_LOGADO, Usuario.class); }//from ww w . ja v a 2s . co m if (!extras.isEmpty()) { // has effect of unparcelling 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. */ if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { String mensagem = extras.getString("mensagem"); if (!mensagem.contains("idImovel")) { Mensagem mensagemO = new Mensagem(); mensagemO.parse(mensagem); this.mensagem = mensagemO; this.mensagem.setLida(false); if (usuarioLogado != null && usuarioLogado.getIdUsuario() == this.mensagem.getUsuariosDestino() .get(0).getIdUsuario()) { sendNotification(mensagemO.getMensagem()); } } else { Imovel imovel = new Imovel(); imovel.parse(mensagem); String stringImovel = "Imovel encontrado em " + imovel.getEstado() + " - " + imovel.getBairro(); sendNotificationImovel(stringImovel); } } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }