List of usage examples for android.content Intent putExtra
@Deprecated
@UnsupportedAppUsage
public @NonNull Intent putExtra(String name, IBinder value)
From source file:Main.java
public static void shareViaIntent(Context context, String subject, String extraText) { Intent sendIntent = new Intent(); sendIntent.setType("text/plain"); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.putExtra(Intent.EXTRA_TEXT, extraText); context.startActivity(sendIntent);//from w w w .j a va 2s .co m }
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); final ArrayList<CharSequence> extraText = new ArrayList<>(1); extraText.add(body);//w w w. j a va 2 s .c o m intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, extraText); if (attachments != null && !attachments.isEmpty()) { intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments)); } return intent; }
From source file:Main.java
public static void takePicture(Activity mActivity, String imagePath) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (null != imagePath && !imagePath.isEmpty()) { intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(imagePath))); }// w ww . j a v a 2 s . c om mActivity.startActivityForResult(intent, BBS_REQUEST_CAMERA); }
From source file:Main.java
public static void mail(Activity activity, String email, String subject, String content) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); intent.putExtra(Intent.EXTRA_SUBJECT, subject); if (content != null) { intent.putExtra(Intent.EXTRA_TEXT, content); }//from ww w .jav a 2 s .com final PackageManager manager = activity.getPackageManager(); final List<ResolveInfo> matches = manager.queryIntentActivities(intent, 0); for (ResolveInfo info : matches) { if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); } else if (info.activityInfo.packageName.endsWith(".email") || info.activityInfo.name.toLowerCase().contains("email")) { intent.setClassName(info.activityInfo.packageName, info.activityInfo.name); } } activity.startActivity(intent); }
From source file:Main.java
/** * Returns an intent calling the android chooser. The chooser will provide apps, which listen to one of the following actions * {@link Intent#ACTION_GET_CONTENT} , {@link MediaStore#ACTION_IMAGE_CAPTURE}, {@link MediaStore#ACTION_VIDEO_CAPTURE}, * {@link MediaStore.Audio.Media#RECORD_SOUND_ACTION} * /* ww w. j a v a2s . c om*/ * @return Intent that opens the app chooser. */ public static Intent getChooserIntent() { // GET_CONTENT Apps Intent getContentIntent = new Intent(); getContentIntent.setAction(Intent.ACTION_GET_CONTENT); getContentIntent.setType("*/*"); getContentIntent.addCategory(Intent.CATEGORY_OPENABLE); // ACTION_IMAGE_CAPTURE Apps Intent captureImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // ACTION_VIDEO_CAPTURE Apps Intent captureVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); // RECORD_SOUND_ACTION Apps Intent recordSoungIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); Intent finalIntent = Intent.createChooser(getContentIntent, "test"); finalIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { captureImageIntent, captureVideoIntent, recordSoungIntent }); return finalIntent; }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String name, Serializable serializable) { Intent intent = new Intent(); intent.putExtra(name, serializable); intent.setAction(filter);//from w w w. j av a 2 s .c o m if (mLocalBroadcastManager == null) { getLocalBroadcastManager(context.getApplicationContext()); } mLocalBroadcastManager.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String name, String value) { Intent intent = new Intent(); intent.putExtra(name, value); intent.setAction(filter);// w w w .j ava 2s . c o m if (mLocalBroadcastManager == null) { getLocalBroadcastManager(context.getApplicationContext()); } mLocalBroadcastManager.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String name, long value) { Intent intent = new Intent(); intent.putExtra(name, value); intent.setAction(filter);/* www . j av a2 s . c o m*/ if (mLocalBroadcastManager == null) { getLocalBroadcastManager(context.getApplicationContext()); } mLocalBroadcastManager.sendBroadcast(intent); }
From source file:Main.java
public static void sendBroadcast(Context context, String filter, String name, int value) { Intent intent = new Intent(); intent.putExtra(name, value); intent.setAction(filter);//from w ww . j av a 2 s.c o m if (mLocalBroadcastManager == null) { getLocalBroadcastManager(context.getApplicationContext()); } mLocalBroadcastManager.sendBroadcast(intent); }
From source file:Main.java
public static void setValueToIntent(Intent intent, String key, Object val) { if (val instanceof Boolean) intent.putExtra(key, (Boolean) val); else if (val instanceof Boolean[]) intent.putExtra(key, (Boolean[]) val); else if (val instanceof String) intent.putExtra(key, (String) val); else if (val instanceof String[]) intent.putExtra(key, (String[]) val); else if (val instanceof Integer) intent.putExtra(key, (Integer) val); else if (val instanceof Integer[]) intent.putExtra(key, (Integer[]) val); else if (val instanceof Long) intent.putExtra(key, (Long) val); else if (val instanceof Long[]) intent.putExtra(key, (Long[]) val); else if (val instanceof Double) intent.putExtra(key, (Double) val); else if (val instanceof Double[]) intent.putExtra(key, (Double[]) val); else if (val instanceof Float) intent.putExtra(key, (Float) val); else if (val instanceof Float[]) intent.putExtra(key, (Float[]) val); }