@Override protected void onHandleIntent(Intent intent) { try { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); sf = getSharedPreferences(Constants.UserInfoSharedPref, MODE_PRIVATE); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Article article = new Article( Integer.parseInt(extras.getString("id")), extras.getString("name"), extras.getString("email"), extras.getString("title"), Integer.parseInt(extras.getString("category")), Long.parseLong(extras.getString("timestamp")), extras.getInt("publisher")); if (sf.getBoolean(Constants.SignInDone, false)) { sendNotification(article); } } } GcmBroadcastReceiver.completeWakefulIntent(intent); } catch (Exception ex) { ex.printStackTrace(); } }
@Override protected void onHandleIntent(Intent intent) { // TODO Auto-generated method stub Bundle extras = intent.getExtras(); String msg = intent.getStringExtra("message"); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { 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)) { // This loop represents the service doing some work. for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(500); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. // sendNotification("Received: " + extras.toString()); sendNotification(msg); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReciever.completeWakefulIntent(intent); }
@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()) { // 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)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { System.out.println(extras.toString()); // Game Logic // if we are on the correct page with correct opponent, update UI Intent responseIntent = new Intent("com.jajmu.GOT_PUSH"); responseIntent.putExtras(extras); sendOrderedBroadcast(responseIntent, null); // otherwise send notification // sendNotification(extras); // int duration = Toast.LENGTH_SHORT; // Toast toast = Toast.makeText(getApplicationContext(), extras.toString(), duration); // toast.show(); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { 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()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { for (int i = 0; i < 3; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification( "Message Received from Google GCM Server: " + extras.get(Config.MESSAGE_KEY)); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); 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)) { 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)) { // This loop represents the service doing some work. String time = intent.getStringExtra("time"); sendNotification("Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { extras = intent.getExtras(); String value = extras.getString("message"); Log.i(TAG, "Bundle 'message' Value = " + value); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); Log.i(TAG, "in gcm intent Message = " + messageType); Log.i(TAG, "in gcm intent Message Bundle = " + extras.toString()); 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 received_message=intent.getStringExtra("text_message"); String received_message = extras.getString("message"); Log.i(TAG, "received_message = " + received_message); if (received_message.equalsIgnoreCase("track")) { Log.i(TAG, "In if block, received_message = " + received_message); Intent i = new Intent(this, DemoLocation.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra("received_message", received_message); startActivity(i); } sendNotification("MESSAGE RECEIVED :" + received_message); Intent sendIntent = new Intent("message_recieved"); sendIntent.putExtra("message", received_message); LocalBroadcastManager.getInstance(this).sendBroadcast(sendIntent); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@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); mes = extras.getString("message"); showNotification(); Log.i("GCM", "Received : (" + messageType + ") " + extras.getString("title")); GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (extras != null && !extras.isEmpty()) { // has effect of unparcelling Bundle // Since we're not using two way messaging, this is all we really to check for if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Logger.getLogger("GCM_RECEIVED").log(Level.INFO, extras.toString()); notifyMe(extras.getString("name"), extras.getString("description")); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { 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()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { sendNotification("Message Received from Google GCM Server:\n\n" + extras.get("message")); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@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()) { // 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)) { // This loop represents the service doing some work. for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. String mensaje = extras.getString("message"); String enlace = extras.getString("link"); String titulo = extras.getString("title"); String imagen = extras.getString("image"); sendNotification(mensaje, enlace, titulo, imagen); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onHandleIntent - context: " + context); // Extract the payload from the message Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (extras != null) { try { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { JSONObject json = new JSONObject(); json.put("event", "error"); json.put("message", extras.toString()); PushPlugin.sendJavascript(json); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { JSONObject json = new JSONObject(); json.put("event", "deleted"); json.put("message", extras.toString()); PushPlugin.sendJavascript(json); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // if we are in the foreground, just surface the payload, else post it to the statusbar if (PushPlugin.isInForeground()) { extras.putBoolean("foreground", true); PushPlugin.sendExtras(extras); } else { extras.putBoolean("foreground", false); // Send a notification if there is a message if (extras.getString("message") != null && extras.getString("message").length() != 0) { createNotification(context, extras); } } } } catch (JSONException exception) { Log.d(TAG, "JSON Exception was had!"); } } }
@Override public void onReceive(Context context, Intent intent) { GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { Log.w(TAG, "GCM message..."); if (!TextSecurePreferences.isGcmRegistered(context)) { Log.w(TAG, "Not GCM registered!"); return; } String messageData = intent.getStringExtra("message"); String receiptData = intent.getStringExtra("receipt"); if (!TextUtils.isEmpty(messageData)) handleReceivedMessage(context, messageData); else if (!TextUtils.isEmpty(receiptData)) handleReceivedMessage(context, receiptData); } }
@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()) { // 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. */ Log.w(TAG, "MessageType: " + messageType + " Extras: " + extras.toString()); Movintracks.getInstance().receivedGoogleCloudMessage(extras); } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); // The getMessageType() intent parameter must be the intent you receive 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)) { sendNotification("Send error: " + extras.toString(), null); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString(), null); // If it's a regular GCM message, do some work } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message String message = extras.toString(); if (Globals.ACTION_CLEAR_NOTIFICATION.equals(extras.getString("action"))) { clearNotification(); } else if (Globals.ACTION_NOTIFICATION.equals(extras.getString("action"))) { sendNotification("Received: " + message, extras); } else { stopProgressBarIfRequired(extras); } Log.v(Globals.TAG, "Received: " + message); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override public void onReceive(Context context, Intent intent) { ctx = context; PowerManager mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE); WakeLock mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); mWakeLock.acquire(); try { GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server"); } else { String msg = intent.getStringExtra(DataProvider.COL_MESSAGE); String senderEmail = intent.getStringExtra(DataProvider.COL_SENDER_EMAIL); String receiverEmail = intent.getStringExtra(DataProvider.COL_RECEIVER_EMAIL); if (!contactExists(senderEmail, context)) { ContentValues values = new ContentValues(2); values.put(DataProvider.COL_NAME, senderEmail.substring(0, senderEmail.indexOf('@'))); values.put(DataProvider.COL_EMAIL, senderEmail); context.getContentResolver().insert(DataProvider.CONTENT_URI_PROFILE, values); } ContentValues values = new ContentValues(2); values.put(DataProvider.COL_TYPE, MessageType.INCOMING.ordinal()); values.put(DataProvider.COL_MESSAGE, msg); values.put(DataProvider.COL_SENDER_EMAIL, senderEmail); values.put(DataProvider.COL_RECEIVER_EMAIL, receiverEmail); context.getContentResolver().insert(DataProvider.CONTENT_URI_MESSAGES, values); if (Common.isNotify()) { newMessageNotification("New message", senderEmail); } } setResultCode(Activity.RESULT_OK); } finally { mWakeLock.release(); } }
@Override protected void onHandleIntent(Intent intent) { context = getApplicationContext(); chatArrayAdapter = new ChatArrayAdapter(getApplicationContext(), R.layout.activity_chat_singlemessage); Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (extras != null) { if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if ("USERLIST".equals(extras.get("SM"))) { // update the userlist view Intent userListIntent = new Intent("com.example.admin.yama.userlist"); String userList = extras.get("USERLIST").toString(); userListIntent.putExtra("USERLIST", userList); sendBroadcast(userListIntent); } else if ("CHAT".equals(extras.get("SM"))) { Log.v("I WIN", "got a chat here"); USER_NAME = extras.get("Sender").toString(); Intent chatIntent = new Intent("com.example.admin.yama.chatmessage"); chatIntent.putExtra("Sender", extras.get("Sender").toString()); chatIntent.putExtra("CHATMESSAGE", extras.get("CHATMESSAGE").toString()); messageNotifictaion(chatIntent); sendBroadcast(chatIntent); } else if ("SIGNUPACK".equals(extras.get("SM"))) { SIGNUP_ACK = "Sign up with server complete"; } else if (Config.GOOGLE_PROJECT_ID.equals(extras.get("from"))) { } } } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Log.i("GCM", "Received a message."); Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // AccountManager accountManager = AccountManager.get(this.getApplicationContext()); // Account[] accounts = // accountManager.getAccountsByType(AuthenticatorActivity.ARG_ACCOUNT_TYPE); // for ( Account account : accounts ) { // //ContentResolver.requestSync(account, GewichtProvider.AUTHORITY, new // Bundle()); // } } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); sharedPreferences = getSharedPreferences("Mydata", Context.MODE_PRIVATE); notification_id = sharedPreferences.getInt("id_notification", 1); SharedPreferences.Editor editor = sharedPreferences.edit(); // The getMessageType() intent parameter must be the intent you received // in your BroadcastReceiver. String messageType = gcm.getMessageType(intent); code = extras.getString("title"); message = extras.getString("message"); if (code.equals("1")) { ticker = "Notificacion: Puerta abierta!"; imagen = R.drawable.door; } else if (code.equals("2")) { ticker = "Notificacion: Luz encendida"; imagen = R.drawable.lights; } else if (code.equals("3")) { ticker = "Notificacion: Alarma sonando"; imagen = R.drawable.alert; } else if (code.equals("4")) { ticker = "Notificacion: Foto recibida"; imagen = R.drawable.picture; request = "http://" + ServerIp + ":8084/FinalServer/webresources/alarmarest/get/media/picture"; requestData(request); } else if (code.equals("5")) { ticker = "Notificacion: Audio recibido"; imagen = R.drawable.audio; request = "http://" + ServerIp + ":8084/FinalServer/webresources/alarmarest/get/media/audio"; requestData(request); } else if (code.equals("6")) { ticker = "Notificacion: Carro en movimiento"; imagen = R.drawable.delivery; // request = // "http://"+ServerIp+":8084/FinalServer/webresources/alarmarest/get/media/audio"; // requestData(request); } Log.i("ALARMA", "NOTIFICATION WORKING"); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext()) .setContentTitle("SSV") .setContentText(message) .setTicker(ticker) .setWhen(System.currentTimeMillis()) .setDefaults(Notification.DEFAULT_SOUND) .setAutoCancel(true) .setSmallIcon(imagen); PendingIntent contentIntent = null; if (code.equals("4")) { contentIntent = PendingIntent.getActivity( this, 0, new Intent(this, PhotoGridView.class), PendingIntent.FLAG_UPDATE_CURRENT); } else if (code.equals("5")) { contentIntent = PendingIntent.getActivity( this, 0, new Intent(this, AudioGridView.class), PendingIntent.FLAG_UPDATE_CURRENT); } else { contentIntent = PendingIntent.getActivity( this, 0, new Intent(this, MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); } mBuilder.setContentIntent(contentIntent); Log.i("ALARMA", "ID NOTIFICACION::" + notification_id); notificationManager.notify(notification_id, mBuilder.build()); notification_id += 1; editor.putInt("id_notification", notification_id); editor.commit(); GcmReceiver.completeWakefulIntent(intent); }
@Override protected void onHandleIntent(Intent intent) { final Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { 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() , ""); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { if (extras.getString("webId") != null && !extras.getString("webId").isEmpty()) { final PostsDataSource postsDataSource = new PostsDataSource(this); postsDataSource.open(); if (postsDataSource.countRow( DB.POST_TABLE, DB.POST_COLUMNS, DB.POST_COLUMN_WEB_ID + " = ? ", new String[] {extras.getString("webId")}, null) == 0) { new WebClient( URL.buildUrl( WebUrl.POST_URL, "20", extras.getString("webId"), null, null, null, null), new Response.Listener<String>() { @Override public void onResponse(String response) { List<Post> postList; postList = WebJSONParser.postParseFeed(response); postsDataSource.insertPosts(postList); new Thread( new Runnable() { @Override public void run() { Post post = postsDataSource.getPost( DB.POST_COLUMN_WEB_ID + " = ? ", new String[] {extras.getString("webId")}, null); String url = ""; try { if (post.getType().equals("drama") || post.getType().equals("column")) { JSONObject image = null; image = new JSONObject(post.getCategoryImage()); url = image.getString("small"); } else { JSONObject image = new JSONObject(post.getImage()); url = image.getString("small"); } } catch (JSONException e) { e.printStackTrace(); } if (!url.isEmpty()) { Bitmap bitmap = getBitmapFromURL(url); sendNotification( "" + extras.get("n"), extras.getString("webId"), bitmap); } } }) .start(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) {} }, Request.Priority.HIGH); } else { new Thread( new Runnable() { @Override public void run() { Post post = postsDataSource.getPost( DB.POST_COLUMN_WEB_ID + " = ? ", new String[] {extras.getString("webId")}, null); String url = ""; try { if (post.getType().equals("drama") || post.getType().equals("column")) { JSONObject image = null; image = new JSONObject(post.getCategoryImage()); url = image.getString("small"); } else { JSONObject image = new JSONObject(post.getImage()); url = image.getString("small"); } } catch (JSONException e) { e.printStackTrace(); } if (!url.isEmpty()) { Bitmap bitmap = getBitmapFromURL(url); sendNotification("" + extras.get("n"), extras.getString("webId"), bitmap); } } }) .start(); } } } } GcmBroadcastReceiver.completeWakefulIntent(intent); }