List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:br.ajmarques.cordova.plugin.localnotification.Receiver.java
@Override public void onReceive(Context context, Intent intent) { Options options = null;/*from w ww. j av a 2 s . c o m*/ Bundle bundle = intent.getExtras(); JSONObject args; try { args = new JSONObject(bundle.getString(OPTIONS)); options = new Options(context).parse(args); } catch (JSONException e) { return; } this.context = context; this.options = options; // The context may got lost if the app was not running before LocalNotification.setContext(context); if (options.getInterval() == 0) { LocalNotification.unpersist(options.getId()); } else if (isFirstAlarmInFuture()) { return; } else { LocalNotification.add(options.moveDate()); } NotificationCompat.Builder notification = buildNotification(); if (!isInBackground(context)) { invokeForegroundCallback(); } showNotification(notification); }
From source file:com.example.mobileid.GcmIntentService.java
private void sendNotification(Intent intent) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Bundle extras = intent.getExtras(); JSONObject gcmObj;/*from w w w .ja v a 2 s . c om*/ try { gcmObj = new JSONObject(extras.getString("message")); String msg = gcmObj.getString("info"); Intent passIntent = new Intent(); passIntent.setClass(this, MainActivity.class); passIntent.putExtra("gcmMsg", gcmObj.toString()); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, passIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); if (msg.compareToIgnoreCase("websign") != 0) { // NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) mBuilder.setSmallIcon(R.drawable.ic_launcher).setContentTitle("mobileID") .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); } else { // NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) mBuilder.setSmallIcon(R.drawable.ic_launcher) .setContentTitle("Web Sign - " + gcmObj.getString("title")) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) .setContentText(gcmObj.getString("content")); } //default notification sound Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setSound(alarmSound); //cleared after clicking mBuilder.setAutoCancel(true); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.pushwoosh.test.plugin.pushnotifications.PushNotifications.java
private void checkMessage(Intent intent) { if (null != intent) { if (intent.hasExtra(PushManager.PUSH_RECEIVE_EVENT)) { doOnMessageReceive(intent.getExtras().getString(PushManager.PUSH_RECEIVE_EVENT)); } else if (intent.hasExtra(PushManager.REGISTER_EVENT)) { doOnRegistered(intent.getExtras().getString(PushManager.REGISTER_EVENT)); } else if (intent.hasExtra(PushManager.UNREGISTER_EVENT)) { doOnUnregisteredError(intent.getExtras().getString(PushManager.UNREGISTER_EVENT)); } else if (intent.hasExtra(PushManager.REGISTER_ERROR_EVENT)) { doOnRegisteredError(intent.getExtras().getString(PushManager.REGISTER_ERROR_EVENT)); } else if (intent.hasExtra(PushManager.UNREGISTER_ERROR_EVENT)) { doOnUnregistered(intent.getExtras().getString(PushManager.UNREGISTER_ERROR_EVENT)); }/*w w w.j a va 2 s .c o m*/ } }
From source file:net.reichholf.dreamdroid.activities.DreamDroidShareActivity.java
@SuppressWarnings("deprecation") private void playOnDream(Profile p) { String url = null;/*w w w . j av a 2 s . c o m*/ Intent i = getIntent(); Bundle extras = i.getExtras(); mShc = SimpleHttpClient.getInstance(p); if (Intent.ACTION_SEND.equals(i.getAction())) url = extras.getString(Intent.EXTRA_TEXT); else if (Intent.ACTION_VIEW.equals(i.getAction())) url = i.getDataString(); if (url != null) { Log.i(LOG_TAG, url); Log.i(LOG_TAG, p.getHost()); String time = DateFormat.getDateFormat(this).format(new Date()); String title = getString(R.string.sent_from_dreamdroid, time); if (extras != null) { // semperVidLinks sends "artist" and "song" attributes for the // youtube video titles String song = extras.getString("song"); if (song != null) { String artist = extras.getString("artist"); if (artist != null) title = artist + " - " + song; } else { String tmp = extras.getString("title"); if (tmp != null) title = tmp; } } mTitle = new String(title); url = URLEncoder.encode(url).replace("+", "%20"); title = URLEncoder.encode(title).replace("+", "%20"); String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title; Log.i(LOG_TAG, ref); ArrayList<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("file", ref)); execSimpleResultTask(params); } else { finish(); } }
From source file:app.androidhive.info.realm.GCM.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); preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*//from w w w .j av a2 s . com * 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.d(TAG, "Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.d(TAG, "Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // Post notification of received message. String title = extras.getString("title", null); String message = extras.getString("description", null); String link = extras.getString("link", null); sendNotification(title, message, link); Log.i(TAG, "Received: " + extras.toString()); } } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.nanostuffs.yurdriver.GCMIntentService.java
@Override protected void onMessage(Context context, Intent intent) { AppLog.Log(TAG, "Received bundle : " + intent.getExtras()); // String message = getString(R.string.gcm_message); System.out.println("data is :- " + intent.getExtras().toString()); String message = intent.getExtras().getString("message"); generateNotification(context, message); AppLog.Log(TAG, "Message is: --->" + message); if (message != null) { if (message.equalsIgnoreCase("change destination")) { try { String team = intent.getExtras().getString("team"); JSONObject jsonObject = new JSONObject(team); String jsoString = jsonObject.getString("request_data"); JSONObject json = new JSONObject(jsoString); JSONObject j = new JSONObject(json.getString("walker")); SharedPreferences pre = getSharedPreferences("changeDest", 0); SharedPreferences.Editor edit = pre.edit(); String split = j.getString("destination"); String[] arr = split.split(","); edit.putString("latChangeDest", arr[0]); edit.putString("lonChangeDest", arr[1]); edit.commit();// ww w . j a va 2 s . c o m } catch (Exception e) { // TODO: handle exception } } else { String team = intent.getExtras().getString("team"); // String team="{\"unique_id\":\"1\"}"; if (team != null) { Intent pushIntent = new Intent(AndyConstants.NEW_REQUEST); pushIntent.putExtra(AndyConstants.NEW_REQUEST, team); // String messageBedge = // intent.getExtras().getString("bedge"); CommonUtilities.displayMessage(context, message); // notifies user try { JSONObject jsonObject = new JSONObject(team); if (jsonObject.getInt(AndyConstants.Params.UNIQUE_ID) == 1) { generateNotification(context, message); } else { preferenceHelper = new PreferenceHelper(context); preferenceHelper.clearRequestData(); } } catch (JSONException e) { e.printStackTrace(); } LocalBroadcastManager.getInstance(context).sendBroadcast(pushIntent); } } } }
From source file:net.reichholf.dreamdroid.activities.ShareActivity.java
@SuppressWarnings("deprecation") private void playOnDream(Profile p) { String url = null;// w ww. j a v a 2 s. c o m Intent i = getIntent(); Bundle extras = i.getExtras(); mShc = SimpleHttpClient.getInstance(p); if (Intent.ACTION_SEND.equals(i.getAction())) url = extras.getString(Intent.EXTRA_TEXT); else if (Intent.ACTION_VIEW.equals(i.getAction())) url = i.getDataString(); if (url != null) { Log.i(LOG_TAG, url); Log.i(LOG_TAG, p.getHost()); String time = DateFormat.getDateFormat(this).format(new Date()); String title = getString(R.string.sent_from_dreamdroid, time); if (extras != null) { // semperVidLinks sends "artist" and "song" attributes for the // youtube video titles String song = extras.getString("song"); if (song != null) { String artist = extras.getString("artist"); if (artist != null) title = artist + " - " + song; } else { String tmp = extras.getString("title"); if (tmp != null) title = tmp; } } mTitle = title; url = URLEncoder.encode(url).replace("+", "%20"); title = URLEncoder.encode(title).replace("+", "%20"); String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title; Log.i(LOG_TAG, ref); ArrayList<NameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair("file", ref)); execSimpleResultTask(params); } else { finish(); } }
From source file:com.pti.mates.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); //sendNotification("Estem fent HandleIntent"); if (!extras.isEmpty()) { // has effect of unparcelling Bundle /*/*w ww. java2s . 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)) { //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)) { //sendNotification("Message type correcte"); // This loop represents the service doing some work. String type = intent.getStringExtra("type"); if (type.equals("message")) { String msg = intent.getStringExtra("data"); String senderid = intent.getStringExtra("sender"); String receiverid = intent.getStringExtra("receiver"); //String senderEmail = intent.getStringExtra(DataProvider.COL_SENDER_EMAIL); //String receiverEmail = intent.getStringExtra(DataProvider.COL_RECEIVER_EMAIL); ContentValues values = new ContentValues(2); values.put(DataProvider.COL_TYPE, MessageType.INCOMING.ordinal()); values.put(DataProvider.COL_MESSAGE, msg); values.put(DataProvider.COL_SENDERFBID, senderid); values.put(DataProvider.COL_RECEIVERFBID, receiverid); getApplicationContext().getContentResolver().insert(DataProvider.CONTENT_URI_MESSAGES, values); if (Common.isNotify()) { /*Cursor c = getApplicationContext().getContentResolver().query(DataProvider.CONTENT_URI_PROFILE, null, DataProvider.COL_FBID + "=" + senderid, null, null); int index = c.getColumnIndex(DataProvider.COL_NAME); String sendername; if (index != -1) { sendername = c.getString(index); } else { sendername = "name not available"; } sendNotificationChat("New message from " + sendername,senderid);*/ sendNotificationChat("New message", senderid); } } else if (type.equals("mate")) { //extreure info de la persona necessaria per crear el xat (insertar a la base de dades un nou perfil) //si fa falta cridar la activity per mostrar la info. (perfilActivity??) String userdatajson = intent.getStringExtra("data"); String fbid = getInfoFromJson(userdatajson, "id"); String name = getInfoFromJson(userdatajson, "name"); Log.d("Mate intent service", "fbid = " + fbid + " name = " + name); ContentValues values = new ContentValues(2); values.put(DataProvider.COL_NAME, name); values.put(DataProvider.COL_FBID, fbid); getApplication().getContentResolver().insert(DataProvider.CONTENT_URI_PROFILE, values); sendNotificationMate("New Mate with " + name); } } /*else { String msg = intent.getExtras().toString(); //String senderEmail = intent.getStringExtra(DataProvider.COL_SENDER_EMAIL); //String receiverEmail = intent.getStringExtra(DataProvider.COL_RECEIVER_EMAIL); String senderid = intent.getStringExtra("sender"); String receiverid = intent.getStringExtra("receiver"); //String senderEmail = intent.getStringExtra(DataProvider.COL_SENDER_EMAIL); //String receiverEmail = intent.getStringExtra(DataProvider.COL_RECEIVER_EMAIL); ContentValues values = new ContentValues(2); values.put(DataProvider.COL_TYPE, MessageType.INCOMING.ordinal()); values.put(DataProvider.COL_MESSAGE, msg); values.put(DataProvider.COL_SENDERFBID, senderid); values.put(DataProvider.COL_RECEIVERFBID, receiverid); getApplicationContext().getContentResolver().insert(DataProvider.CONTENT_URI_MESSAGES, values); if (Common.isNotify()) { sendNotification("New message"); } }*/ } else { //sendNotification("Extras empty"); } // Release the wake lock provided by the WakefulBroadcastReceiver. GcmBroadcastReceiver.completeWakefulIntent(intent); }
From source file:uk.co.gidley.clockRadio.RadioPlayerService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { String url = intent.getExtras().getString(URL); this.play(url); return START_STICKY; }
From source file:jp.co.conit.sss.sn.ex1.service.RegistService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { // registration_id??????SamuraiNotificationServer?registration_id??? Bundle extras = intent.getExtras(); if (extras != null) { String registrationId = extras.getString("registration_id"); if (!StringUtil.isEmpty(registrationId)) { SendSamuraiNotificationServerTask task = new SendSamuraiNotificationServerTask( getApplicationContext()); task.execute(registrationId); } else {/*w w w . ja va 2s . co m*/ ResponseHandler.registedResponse(); } } return START_NOT_STICKY; }