List of usage examples for android.content Intent EXTRA_INITIAL_INTENTS
String EXTRA_INITIAL_INTENTS
To view the source code for android.content Intent EXTRA_INITIAL_INTENTS.
Click Source Link
From source file:Main.java
public static Intent buildVideoIntent(Context context, Uri uri) { String title = "Choose photo"; //Build galleryIntent Intent galleryIntent = new Intent(Intent.ACTION_PICK); galleryIntent.setType("video/*"); //Create chooser Intent chooser = Intent.createChooser(galleryIntent, title); Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); Intent[] extraIntents = { cameraIntent }; chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); return chooser; }
From source file:Main.java
public static Intent createTakePictureIntent(@NonNull Context context, @NonNull Uri outputFileUri) { List<Intent> cameraIntents = createTakePictureIntentList(context, outputFileUri); if (cameraIntents.isEmpty()) return null; Intent chooserIntent = new Intent(cameraIntents.get(0)); cameraIntents.remove(0);//from ww w . j a v a2s . c o m chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); return chooserIntent; }
From source file:Main.java
public static Intent getImageFromGalleryCamera(Context context) { // Determine Uri of camera image to save. File root = new File( Environment.getExternalStorageDirectory() + File.separator + "dianta/camera" + File.separator); root.mkdirs();/* w w w .j a v a 2 s . c om*/ String fname = "dianta-" + System.currentTimeMillis() + ".jpg"; File sdImageMainDirectory = new File(root, fname); Uri outputFileUri = Uri.fromFile(sdImageMainDirectory); // camera List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); PackageManager lPackageManager = context.getPackageManager(); List<ResolveInfo> listCam = lPackageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo rInfo : listCam) { String packageName = rInfo.activityInfo.packageName; Intent lIntent = new Intent(captureIntent); lIntent.setComponent(new ComponentName(rInfo.activityInfo.packageName, rInfo.activityInfo.name)); lIntent.setPackage(packageName); //save camera result to external storage lIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(lIntent); } //ugly hacks for camera helper lastCameraImageSaved = outputFileUri; // gallery Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); Intent chooserIntent = Intent.createChooser(galleryIntent, "Pilih Sumber"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); return chooserIntent; }
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} * /*from w ww . j a v a 2 s . 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
/** * Intent chooser is customized to remove unwanted apps. * 1. FaceBook has bug where only links can be shared. * 2. Cannot share this type of content via Google Docs and Skype. *//*w w w . j a v a 2 s . c o m*/ public static void ShareResult(Context mContext, String mResult, String mTitle) { List<Intent> targetedShareIntents = new ArrayList<Intent>(); Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); List<ResolveInfo> resInfo = mContext.getPackageManager().queryIntentActivities(shareIntent, 0); if (!resInfo.isEmpty()) { for (ResolveInfo resolveInfo : resInfo) { String packageName = resolveInfo.activityInfo.packageName; Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND); targetedShareIntent.setType("text/plain"); targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mTitle); targetedShareIntent.putExtra(android.content.Intent.EXTRA_TITLE, mTitle); targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, mResult); if (!packageName.toLowerCase().contains("com.facebook.katana") && !packageName.toLowerCase().contains("com.google.android.apps.docs") && !packageName.toLowerCase().contains("com.skype.raider")) { targetedShareIntent.setPackage(packageName); targetedShareIntents.add(targetedShareIntent); } } Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Send your result"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {})); mContext.startActivity(chooserIntent); } return; }
From source file:Main.java
public static void openMailChooser(Context context, String text, String[] mails, String subject) { Intent mailIntent = new Intent(); mailIntent.setAction(Intent.ACTION_SEND); mailIntent.putExtra(Intent.EXTRA_TEXT, text); mailIntent.putExtra(Intent.EXTRA_EMAIL, mails); mailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); mailIntent.setType(INTENT_TYPE_MSG); PackageManager pm = context.getPackageManager(); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType(INTENT_TYPE_TEXT); Intent openInChooser = Intent.createChooser(mailIntent, ""); List<ResolveInfo> resInfo = pm.queryIntentActivities(sendIntent, 0); List<LabeledIntent> intentList = new ArrayList<LabeledIntent>(); for (ResolveInfo ri : resInfo) { String packageName = ri.activityInfo.packageName; if (packageName.contains(PACKAGE_EMAIL)) { mailIntent.setPackage(packageName); } else if (packageName.contains(PACKAGE_MMS) || packageName.contains(PACKAGE_GMAIL)) { Intent intent = new Intent(); intent.setComponent(new ComponentName(packageName, ri.activityInfo.name)); intent.setAction(Intent.ACTION_SEND); intent.setType(INTENT_TYPE_TEXT); if (packageName.contains(PACKAGE_MMS)) { intent.putExtra("subject", subject); intent.putExtra("sms_body", text); intent.putExtra("address", mails[0]); intent.setType(INTENT_TYPE_MSG); } else if (packageName.contains(PACKAGE_GMAIL)) { intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_EMAIL, mails); intent.setType(INTENT_TYPE_MSG); }/*from w w w . j a v a 2 s . c o m*/ intentList.add(new LabeledIntent(intent, packageName, ri.loadLabel(pm), ri.icon)); } } LabeledIntent[] extraIntents = intentList.toArray(new LabeledIntent[intentList.size()]); openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents); context.startActivity(openInChooser); }
From source file:com.pdftron.pdf.utils.ViewerUtils.java
public static Uri openImageIntent(Fragment fragment, int requestCode) { // Determine Uri of camera image to save. final String fname = "IMG_" + System.currentTimeMillis() + ".jpg"; File sdImageMainDirectory = new File(fragment.getActivity().getExternalCacheDir(), fname); Uri outputFileUri = Uri.fromFile(sdImageMainDirectory); // Camera.// w w w. j av a2 s. c o m final List<Intent> cameraIntents = new ArrayList<>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = fragment.getActivity().getPackageManager(); final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { final String packageName = res.activityInfo.packageName; final Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(intent); } // Filesystem. final Intent galleryIntent = new Intent(Intent.ACTION_PICK); galleryIntent.setType("image/*"); //galleryIntent.setAction(Intent.ACTION_GET_CONTENT); // Chooser of filesystem options. final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source"); // Add the camera options. chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {})); fragment.startActivityForResult(chooserIntent, requestCode); return outputFileUri; }
From source file:com.manning.androidhacks.hack035.MainActivity.java
public void onPickBoth(View v) { Intent pickIntent = new Intent(Intent.ACTION_GET_CONTENT); pickIntent.setType("image/*"); Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Intent chooserIntent = Intent.createChooser(pickIntent, getString(R.string.activity_main_pick_both)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takePhotoIntent }); startActivityForResult(chooserIntent, PICK_OR_TAKE_PICTURE); }
From source file:com.android.browser.UploadHandler.java
void openFileChooser(ValueCallback<Uri[]> callback, FileChooserParams fileChooserParams) { if (mUploadMessage != null) { // Already a file picker operation in progress. return;// ww w .j a va 2 s . co m } mUploadMessage = callback; mParams = fileChooserParams; Intent[] captureIntents = createCaptureIntent(); assert (captureIntents != null && captureIntents.length > 0); Intent intent = null; // Go to the media capture directly if capture is specified, this is the // preferred way. if (fileChooserParams.isCaptureEnabled() && captureIntents.length == 1) { intent = captureIntents[0]; } else { intent = new Intent(Intent.ACTION_CHOOSER); intent.putExtra(Intent.EXTRA_INITIAL_INTENTS, captureIntents); intent.putExtra(Intent.EXTRA_INTENT, fileChooserParams.createIntent()); } startActivity(intent); }
From source file:com.teegarcs.mocker.internals.MockerInternals.java
public static Intent generateShareViewIntent(Context context, Uri uri) { //share intent Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType(context.getContentResolver().getType(uri)); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); //view intent Intent viewIntent = new Intent(Intent.ACTION_VIEW); viewIntent.setData(uri);/*from www .j a v a 2 s. com*/ viewIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Intent chooserIntent = Intent.createChooser(shareIntent, "Share"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { viewIntent }); return chooserIntent; }