List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:biz.atelecom.communicator.MyGcmListenerService.java
private void sendNotification(Bundle data) { //Intent intent = new Intent(this, ChatActivity.class); Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtras(data); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.atelecom_ic_notification).setContentTitle("Atelecom Message") .setContentText("message").setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:cn.count.easydrive366.CarRegistrationEditActivity.java
@Override public void processMessage(int msgType, final Object result) { super.processMessage(msgType, result); Bundle bundle = new Bundle(); bundle.putString("result", result.toString()); Intent intent = new Intent(); intent.putExtras(bundle); setResult(RESULT_OK, intent);/* ww w . j av a2 s .com*/ finish(); }
From source file:com.conduit.plastic.common.BaseFragment.java
protected void openActivity(Class<? extends BaseActivity> toActivity, Bundle parameter) { Intent intent = new Intent(getActivity(), toActivity); if (parameter != null) { intent.putExtras(parameter); }//ww w .j av a 2s . c o m startActivity(intent); }
From source file:com.facebook.login.LoginFragment.java
private void onLoginClientCompleted(LoginClient.Result outcome) { request = null;// ww w. j ava 2 s . c o m int resultCode = (outcome.code == LoginClient.Result.Code.CANCEL) ? Activity.RESULT_CANCELED : Activity.RESULT_OK; Bundle bundle = new Bundle(); bundle.putParcelable(RESULT_KEY, outcome); Intent resultIntent = new Intent(); resultIntent.putExtras(bundle); // The activity might be detached we will send a cancel result in onDetach if (isAdded()) { getActivity().setResult(resultCode, resultIntent); getActivity().finish(); } }
From source file:amhamogus.com.daysoff.EventsActivity.java
/** * Launches {@link SingleEventActivity} when the user selects a * row item, that represents a single event. * * @param message TODO//from www . j a v a2 s. co m * @param event An instance of {@link DaysOffEvent}. */ public void onFragmentInteraction(String message, DaysOffEvent event) { Bundle args = new Bundle(); args.putString("DESC", event.getDesc()); args.putString("TIME", event.getTimeRange()); args.putString("LOCATION", event.getLocation()); Intent intent = new Intent(getApplicationContext(), SingleEventActivity.class); intent.putExtras(args); startActivity(intent); }
From source file:org.umit.icm.mobile.social.TwitterUpdate.java
/** * Sends a Tweet using the Notification Service. * /*from w w w. j a va2s . c o m*/ * @param message An object of type String which represents the Tweet. * @see Intent */ public synchronized void sendTweet(String message, Context context) { Bundle bundle = new Bundle(); bundle.putString("twitter", message); Intent intent = new Intent("org.umit.icm.mobile.TWITTER_SERVICE"); intent.putExtras(bundle); context.sendBroadcast(intent); }
From source file:com.nadmm.airports.library.LibraryService.java
protected void handleProgress(int resultCode, Bundle resultData) { Intent intent = new Intent(ACTION_DOWNLOAD_PROGRESS); intent.putExtras(resultData);//www. j a va 2s. c o m LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this); bm.sendBroadcast(intent); }
From source file:mobisocial.musubi.ui.fragments.ChooseImageDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()).setTitle("Choose an Image...") .setItems(new String[] { "From Camera", "From Gallery" }, new DialogInterface.OnClickListener() { @SuppressWarnings("deprecation") @Override/* w w w. j ava 2s. c o m*/ public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: final Activity activity = getActivity(); Toast.makeText(activity, "Loading camera...", Toast.LENGTH_SHORT).show(); ((InstrumentedActivity) activity) .doActivityForResult(new PhotoTaker(activity, new PhotoTaker.ResultHandler() { @Override public void onResult(Uri imageUri) { Log.d(getClass().getSimpleName(), "Updating thumbnail..."); try { UriImage image = new UriImage(activity, imageUri); byte[] data = image.getResizedImageData(512, 512, PictureObj.MAX_IMAGE_SIZE / 2); // profile Bitmap sourceBitmap = BitmapFactory.decodeByteArray(data, 0, data.length); int width = sourceBitmap.getWidth(); int height = sourceBitmap.getHeight(); int cropSize = Math.min(width, height); Bitmap cropped = Bitmap.createBitmap(sourceBitmap, 0, 0, cropSize, cropSize); ByteArrayOutputStream baos = new ByteArrayOutputStream(); cropped.compress(Bitmap.CompressFormat.JPEG, 90, baos); cropped.recycle(); sourceBitmap.recycle(); Bundle bundle = new Bundle(); bundle.putByteArray(EXTRA_THUMBNAIL, baos.toByteArray()); Intent res = new Intent(); res.putExtras(bundle); getTargetFragment().onActivityResult(REQUEST_PROFILE_PICTURE, Activity.RESULT_OK, res); } catch (Throwable t) { Log.e("ViewProfile", "failed to generate thumbnail of profile", t); Toast.makeText(activity, "Profile picture capture failed. Try again.", Toast.LENGTH_SHORT).show(); } } }, 200, false)); break; case 1: Intent gallery = new Intent(Intent.ACTION_GET_CONTENT); gallery.setType("image/*"); // god damn fragments. getTargetFragment().startActivityForResult(Intent.createChooser(gallery, null), REQUEST_GALLERY_THUMBNAIL); break; } } }).create(); }
From source file:com.bufarini.reminders.AlarmReceiver.java
private void showNotification(Context context, Intent intent) { Intent snoozeIntent = new Intent(context, NotificationActivity.class); snoozeIntent.putExtras(intent.getExtras()); snoozeIntent.putExtra("notificaton action", "snooze"); PendingIntent snoozePendingIntent = PendingIntent.getActivity(context, 0, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent doneIntent = new Intent(context, NotificationActivity.class); doneIntent.putExtras(intent.getExtras()); doneIntent.putExtra("notificaton action", "done"); doneIntent.putExtra("task", intent.getSerializableExtra("task")); PendingIntent donePendingIntent = PendingIntent.getActivity(context, 1, doneIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent resultIntent = new Intent(context, Reminders.class); resultIntent.putExtra("action", "view task"); resultIntent.putExtra("task", intent.getSerializableExtra("task")); resultIntent.setFlags(//w w w . j av a2 s . c o m Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setAutoCancel(true) .setSmallIcon(R.drawable.ic_action_alarms) .setContentTitle(context.getResources().getString(R.string.alarmPopupTitle1)) .setContentIntent(resultPendingIntent) .addAction(R.drawable.ic_action_alarms, "Snooze", snoozePendingIntent) .addAction(R.drawable.ic_action_done, "Done", donePendingIntent) .setContentText(intent.getExtras().getString(NotificationUtils.TITLE)); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); int notificationId = NotificationUtils.getNotificationId(intent.getExtras().getLong(NotificationUtils.ID)); notificationManager.notify(notificationId, builder.build()); }
From source file:com.rampgreen.caretakermobile.GcmIntentService.java
private void sendNotification(String notificationTitle, String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Bundle bundle = new Bundle(); bundle.putString(Constants.NOTIFICATION_MSG, msg); bundle.putString(Constants.CALLED_COMPONENT, Constants.SERVICE_GCM_INTENT); Intent notificationIntent = new Intent(this, ActivityNotification.class); notificationIntent.putExtras(bundle); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(notificationTitle) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); mBuilder.setContentIntent(contentIntent); Notification notification = mBuilder.build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; mNotificationManager.notify(NOTIFICATION_ID, notification); }