List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:Main.java
@NonNull public static Intent sendEmail(@NonNull String[] to, @NonNull String subject, @NonNull String body, @Nullable List<Uri> attachments) { final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); }/*from w w w .ja v a 2 s. c o m*/ return intent; }
From source file:Main.java
public static void createShortcut(Context context, String shortcutName, int drawableResId, Intent shortcutIntent) { Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT"); shortcutintent.putExtra("duplicate", false); shortcutintent.putExtra("android.intent.extra.shortcut.NAME", shortcutName); shortcutintent.putExtra("android.intent.extra.shortcut.ICON_RESOURCE", Intent.ShortcutIconResource.fromContext(context, drawableResId)); shortcutintent.putExtra("android.intent.extra.shortcut.INTENT", shortcutIntent); context.sendBroadcast(shortcutintent); }
From source file:Main.java
public static void sendBroadCast(Context context, String action, String key, String value) { Intent intent = new Intent(); intent.setAction(action);/* w w w .j a v a 2s . com*/ intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(key, value); context.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadCast(Context context, String action, String key, int value) { Intent intent = new Intent(); intent.setAction(action);/*ww w . j a v a 2s. co m*/ intent.addCategory(Intent.CATEGORY_DEFAULT); intent.putExtra(key, value); context.sendBroadcast(intent); }
From source file:Main.java
public static void setAirplaneMode(Context context, boolean newStatus) { boolean airplaneModeOn = isAirplaneModeOn(context); if (airplaneModeOn && newStatus) { return;//from w w w.ja v a 2 s .c o m } if (!airplaneModeOn && !newStatus) { return; } if (airplaneModeOn && !newStatus) { Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", 0); context.sendBroadcast(intent); return; } if (!airplaneModeOn && newStatus) { Settings.System.putInt(context.getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 1); Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", 1); context.sendBroadcast(intent); return; } }
From source file:Main.java
public static void getPhotoFromCamera(Activity context, int requestCode, Uri imageUri) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // set the image file name context.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void sendEmail(Context context, String chooserTitle, String mailAddress, String subject, String preContent) {//from w w w .j a v a 2 s.co m final Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { mailAddress }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); String content = "\n\n=====================\n"; content += "Device Environment: \n----\n" + preContent; emailIntent.putExtra(Intent.EXTRA_TEXT, content); context.startActivity(Intent.createChooser(emailIntent, chooserTitle)); }
From source file:Main.java
public static void startEmailIntent(Context context, String emailAddress) { try {//from ww w. j a va 2s . c o m Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailAddress }); context.startActivity(intent); } catch (Exception ex) { Log.e(TAG, "Error starting email intent.", ex); Toast.makeText(context, "Sorry, we couldn't find any app for sending emails!", Toast.LENGTH_SHORT) .show(); } }
From source file:com.manning.androidhacks.hack004.util.LaunchEmailUtil.java
public static void launchEmailToIntent(Context context) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "feed@back.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "[50AH] Feedback"); intent.putExtra(Intent.EXTRA_TEXT, "Feedback:\n"); context.startActivity(Intent.createChooser(intent, "Send feedback")); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String bundleName, Bundle bundle) { if (context == null) { return;/*w ww . j a v a 2s . c o m*/ } Intent intent = new Intent(); intent.setAction(filter); intent.putExtra(bundleName, bundle); context.sendBroadcast(intent); }