Java Code Examples for android.content.Intent#ACTION_PICK
The following examples show how to use
android.content.Intent#ACTION_PICK .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: candybar File: IntentHelper.java License: Apache License 2.0 | 6 votes |
public static int getAction(@Nullable Intent intent) { if (intent == null) return ACTION_DEFAULT; String action = intent.getAction(); if (action != null) { switch (action) { case ACTION_ADW_PICK_ICON: case ACTION_TURBO_PICK_ICON: case ACTION_LAWNCHAIR_ICONPACK: case ACTION_NOVA_LAUNCHER: case ACTION_ONEPLUS_PICK_ICON: case ACTION_PLUS_HOME: return ICON_PICKER; case Intent.ACTION_PICK: case Intent.ACTION_GET_CONTENT: return IMAGE_PICKER; case Intent.ACTION_SET_WALLPAPER: return WALLPAPER_PICKER; default: return ACTION_DEFAULT; } } return ACTION_DEFAULT; }
Example 2
Source Project: 1Rramp-Android File: CreateArticleActivity.java License: MIT License | 6 votes |
private void openGallery() { try { leftActivityWithPurpose = true; if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQUEST_IMAGE_SELECTOR); } else { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(intent, REQUEST_IMAGE_SELECTOR); } } catch (Exception e) { e.printStackTrace(); } }
Example 3
Source Project: MagicalCamera File: ActionPicture.java License: Apache License 2.0 | 6 votes |
/** * This call the intent to selected the picture for activity screen * @param headerName the header name of popUp that you need to shown * @return return true if the photo was taken or false if it was not. */ public boolean selectedPicture(String headerName) { try { Intent intent = new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); this.actionPictureObject.getActivity().startActivityForResult( Intent.createChooser(intent, (!headerName.equals("") ? headerName : "Magical Camera")), MagicalCamera.SELECT_PHOTO); return true; }catch (Exception ev){ return false; } }
Example 4
Source Project: iBeebo File: SelectImgUtil.java License: GNU General Public License v3.0 | 6 votes |
public ArrayList<String> listAlldir() { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); Uri uri = intent.getData(); ArrayList<String> list = new ArrayList<String>(); String[] proj = { MediaStore.Images.Media.DATA }; String orderBy = MediaStore.Images.Media.DATE_TAKEN + " DESC"; Cursor cursor = context.getContentResolver().query(uri, proj, null, null, orderBy); if (cursor == null) { return null; } while (cursor.moveToNext()) { String path = cursor.getString(0); list.add(new File(path).getAbsolutePath()); } return list; }
Example 5
Source Project: zxingfragmentlib File: ShareActivity.java License: Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.setClassName(ShareActivity.this, AppPickerActivity.class.getName()); startActivityForResult(intent, PICK_APP); }
Example 6
Source Project: GravityBox File: PickImageActivity.java License: Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mProgressDialog = new ProgressDialog(PickImageActivity.this); mProgressDialog.setMessage(getString(R.string.lc_please_wait)); mProgressDialog.setIndeterminate(true); mProgressDialog.setCancelable(false); Intent startIntent = getIntent(); if (savedInstanceState == null && startIntent != null) { mCropImage = startIntent.getBooleanExtra(EXTRA_CROP, false); mScale = startIntent.getBooleanExtra(EXTRA_SCALE, false); mScaleUp = startIntent.getBooleanExtra(EXTRA_SCALE_UP, false); if (startIntent.hasExtra(EXTRA_ASPECT_X) || startIntent.hasExtra(EXTRA_ASPECT_Y)) { mAspectSize = new Point(startIntent.getIntExtra(EXTRA_ASPECT_X, 0), startIntent.getIntExtra(EXTRA_ASPECT_Y, 0)); } if (startIntent.hasExtra(EXTRA_OUTPUT_X) || startIntent.hasExtra(EXTRA_OUTPUT_Y)) { mOutputSize = new Point(startIntent.getIntExtra(EXTRA_OUTPUT_X, 0), startIntent.getIntExtra(EXTRA_OUTPUT_Y, 0)); } if (startIntent.hasExtra(EXTRA_SPOTLIGHT_X) || startIntent.hasExtra(EXTRA_SPOTLIGHT_Y)) { mSpotlightSize = new Point(startIntent.getIntExtra(EXTRA_SPOTLIGHT_X, 0), startIntent.getIntExtra(EXTRA_SPOTLIGHT_Y, 0)); } Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, getString(R.string.imgpick_dialog_title)), REQ_PICK_IMAGE); } else { finish(); } }
Example 7
Source Project: friendlypix-android File: NewPostActivity.java License: Apache License 2.0 | 5 votes |
@AfterPermissionGranted(RC_CAMERA_PERMISSIONS) private void showImagePicker() { // Check for camera permissions if (!EasyPermissions.hasPermissions(this, cameraPerms)) { EasyPermissions.requestPermissions(this, "This sample will upload a picture from your Camera", RC_CAMERA_PERMISSIONS, cameraPerms); return; } // Choose file storage location File file = new File(getExternalCacheDir(), UUID.randomUUID().toString()); mFileUri = Uri.fromFile(file); // Camera final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = 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(packageName, res.activityInfo.name)); intent.setPackage(packageName); intent.putExtra(MediaStore.EXTRA_OUTPUT, mFileUri); cameraIntents.add(intent); } // Image Picker Intent pickerIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); Intent chooserIntent = Intent.createChooser(pickerIntent, getString(R.string.picture_chooser_title)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); startActivityForResult(chooserIntent, TC_PICK_IMAGE); }
Example 8
Source Project: Nimbus File: UploadNewsFeedActivity.java License: GNU General Public License v3.0 | 5 votes |
private void createChooser() { if(ContextCompat.checkSelfPermission(UploadNewsFeedActivity.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)== PackageManager.PERMISSION_DENIED){ if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){ requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 121); } return; } Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "CHOOSE PHOTO"), PICK_IMAGE_REQUEST); }
Example 9
Source Project: showCaseCordova File: ContactManager.java License: Apache License 2.0 | 5 votes |
/** * Launches the Contact Picker to select a single contact. */ private void pickContactAsync() { final CordovaPlugin plugin = (CordovaPlugin) this; Runnable worker = new Runnable() { public void run() { Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI); plugin.cordova.startActivityForResult(plugin, contactPickerIntent, CONTACT_PICKER_RESULT); } }; this.cordova.getThreadPool().execute(worker); }
Example 10
Source Project: Status File: ImagePickerActivity.java License: Apache License 2.0 | 5 votes |
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if (!StaticUtils.isPermissionsGranted(this, permissions)) { Toast.makeText(this, R.string.msg_missing_storage_permission, Toast.LENGTH_SHORT).show(); finish(); } else { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(intent, ACTION_PICK_IMAGE); } }
Example 11
Source Project: Nimbus File: NewsfeedTry.java License: GNU General Public License v3.0 | 5 votes |
private void createChooser() { if (ContextCompat.checkSelfPermission(NewsfeedTry.this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 121); } return; } Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "CHOOSE PHOTO"), PICK_IMAGE_REQUEST); }
Example 12
Source Project: sana.mobile File: Sana.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Starts Activity for selecting and then viewing a previous encounter */ private void pickSavedProcedure() { Intent i = new Intent(Intent.ACTION_PICK); i.setType(Encounters.CONTENT_TYPE); i.setData(Encounters.CONTENT_URI); onSaveAppState(i); startActivityForResult(i, PICK_SAVEDPROCEDURE); }
Example 13
Source Project: GPS2SMS File: MainActivity.java License: GNU General Public License v3.0 | 5 votes |
public void chooseContact(View v) { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); startActivityForResult(intent, ACT_RESULT_CHOOSE_CONTACT); //IncomingSms.sendNotification(MainActivity.this, "56.5555555,56.7777777"); }
Example 14
Source Project: HaiNaBaiChuan File: BottomSheetImagePicker.java License: Apache License 2.0 | 5 votes |
/** * This checks to see if there is a suitable activity to handle the `ACTION_PICK` intent * and returns it if found. {@link Intent#ACTION_PICK} is for picking an image from an external app. * * @return A prepared intent if found. */ @Nullable private Intent createPickIntent() { if (pickerType != PickerType.CAMERA) { Intent picImageIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); if (picImageIntent.resolveActivity(getActivity().getPackageManager()) != null) { return picImageIntent; } } return null; }
Example 15
Source Project: openlauncher File: ShareUtil.java License: Apache License 2.0 | 5 votes |
/** * Request a picture from gallery * Result will be available from {@link Activity#onActivityResult(int, int, Intent)}. * It will return the path to the image if locally stored. If retrieved from e.g. a cloud * service, the image will get copied to app-cache folder and it's path returned. */ public void requestGalleryPicture() { if (!(_context instanceof Activity)) { throw new RuntimeException("Error: ShareUtil.requestGalleryPicture needs an Activity Context."); } Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); try { ((Activity) _context).startActivityForResult(intent, REQUEST_PICK_PICTURE); } catch (Exception ex) { Toast.makeText(_context, "No gallery app installed!", Toast.LENGTH_SHORT).show(); } }
Example 16
Source Project: abelana File: UploadFragment.java License: Apache License 2.0 | 4 votes |
/** * Starts the select photo intent. */ private void selectPhoto() { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, SELECT_PHOTO_INTENT); }
Example 17
Source Project: Blur File: BlurActivity.java License: Apache License 2.0 | 4 votes |
public static void chooseGalleryImage(Activity activity, int requestCode) { Intent intent = new Intent(Intent.ACTION_PICK, null); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); activity.startActivityForResult(intent, requestCode); }
Example 18
Source Project: MagicLight-Controller File: MainActivity.java License: Apache License 2.0 | 4 votes |
@OnClick(R.id.palette) public void btn_Palette(View v) { Intent intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, RESULT_LOAD_IMAGE); }
Example 19
Source Project: android-profile File: ExampleSocialActivity.java License: Apache License 2.0 | 4 votes |
private void chooseImageFile() { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, SELECT_PHOTO_ACTION); }
Example 20
Source Project: quickhybrid-android File: PhotoSelector.java License: BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Activity调用系统相册 * * @param activity * @param requestCode */ public void requestPhotoPick(Activity activity, int requestCode) { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); activity.startActivityForResult(intent, requestCode); }