List of usage examples for android.content Intent ACTION_PICK
String ACTION_PICK
To view the source code for android.content Intent ACTION_PICK.
Click Source Link
From source file:org.y20k.transistor.MainActivityFragment.java
private void selectFromImagePicker() { // permission to read external storage granted if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { // get system picker for images Intent pickImageIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickImageIntent, REQUEST_LOAD_IMAGE); }/*ww w . j av a 2s. co m*/ // permission to read external storage not granted else { if (ActivityCompat.shouldShowRequestPermissionRationale(mActivity, Manifest.permission.READ_EXTERNAL_STORAGE)) { // ask for permission and explain why Snackbar snackbar = Snackbar.make(mRootView, R.string.snackbar_request_storage_access, Snackbar.LENGTH_INDEFINITE); snackbar.setAction(R.string.dialog_generic_button_okay, new View.OnClickListener() { @Override public void onClick(View view) { requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, PERMISSION_REQUEST_READ_EXTERNAL_STORAGE); } }); snackbar.show(); } else { // ask for permission without explanation requestPermissions(new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, PERMISSION_REQUEST_READ_EXTERNAL_STORAGE); } } }
From source file:com.supremainc.biostar2.user.MyProfileFragment.java
private void editUserImage() { if (Build.VERSION.SDK_INT >= 23) { if ((ActivityCompat.checkSelfPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) || (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) { ActivityCompat/*from w ww. j av a 2s. co m*/ .requestPermissions(mContext, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE }, Setting.REQUEST_EXTERNAL_STORAGE); return; } } SelectPopup<SelectCustomData> selectPopup = new SelectPopup<SelectCustomData>(mContext, mPopup); ArrayList<SelectCustomData> linkType = new ArrayList<SelectCustomData>(); linkType.add(new SelectCustomData(getString(R.string.take_picture), TAKE_PICTURE, false)); linkType.add(new SelectCustomData(getString(R.string.from_gallery), FROM_GALLERY, false)); linkType.add(new SelectCustomData(getString(R.string.delete_picture), DELETE_PICTURE, false)); selectPopup.show(SelectType.CUSTOM, new OnSelectResultListener<SelectCustomData>() { @Override public void OnResult(ArrayList<SelectCustomData> selectedItem) { if (isInValidCheck(null)) { return; } if (selectedItem == null) { return; } int type = selectedItem.get(0).getIntId(); switch (type) { case TAKE_PICTURE: { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, ImageUtil.getTempFileUri()); startActivityForResult(intent, REQ_ACTIVITY_CAMERA); break; } case FROM_GALLERY: { Intent intent = ImageUtil.getImageActionIntent(Intent.ACTION_PICK, false, Setting.USER_PROFILE_IMAGE_SIZE, Setting.USER_PROFILE_IMAGE_SIZE); startActivityForResult(intent, REQ_ACTIVITY_CAMERA_CROP); break; } case DELETE_PICTURE: { mUserInfo.photo = ""; mPhotoStatus = PhotoStatus.DELETE; mLayout.setUserPhotoDefault(); mLayout.setBlurBackGroudDefault(); mBackupPhoto = null; break; } } } }, linkType, getString(R.string.edit_photo), false); }
From source file:com.inter.trade.ui.fragment.smsreceivepayment.SmsReceivePaymentMainFragment.java
/** * //from w ww .j a va2s .com */ private void addressBook() { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent, 2); }
From source file:com.brandroidtools.filemanager.activities.PickerActivity.java
private Uri getResultUriForFileFromIntent(File src, Intent intent) { Uri result = Uri.fromFile(src);//from w w w.j a v a 2 s . c o m if (Intent.ACTION_PICK.equals(intent.getAction()) && intent.getData() != null) { String scheme = intent.getData().getScheme(); if (scheme != null) { result = result.buildUpon().scheme(scheme).build(); } } return result; }
From source file:com.nuvolect.securesuite.main.SharedMenu.java
public static void sharedOnRequestPermissionsResult(Activity act, int requestCode, String[] permissions, int[] grantResults) { switch (requestCode) { /**// ww w . ja v a 2 s. c om * Service the result of a permission request */ case CConst.IMPORT_VCARD_REQUEST_EXTERNAL_STORAGE: { // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Kickoff a browser activity here. // When user selects file, onActivityResult called with the result. Intent intent = new Intent(); intent.setClass(act, FileBrowserImportVcf.class); act.startActivityForResult(intent, CConst.IMPORT_VCARD_BROWSE_ACTION); } else { Toast.makeText(act, "Sorry, external storage permission required for import", Toast.LENGTH_SHORT) .show(); } break; } case CConst.IMPORT_SINGLE_CONTACT_REQUEST_READ: { /** * Launch the contact picker intent. * Results returned in onActivityResult() */ Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); m_act.startActivityForResult(contactPickerIntent, CConst.IMPORT_SINGLE_CONTACT_PICKER); break; } case CConst.IMPORT_ACCOUNT_CONTACTS_REQUEST_READ_CONTACTS: { // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { CloudImportDialog.openDialog(act); } else { Toast.makeText(m_act, "Sorry, read contacts permission required for import", Toast.LENGTH_SHORT) .show(); } break; } case CConst.CALLER_ID_REQUEST_READ_PHONE_STATE: // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Do nothing // Toast.makeText(m_act, "Caller identification enabled", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(m_act, "Calls will not be identified without Read Phone State", Toast.LENGTH_SHORT) .show(); } break; case CConst.REQUEST_WRITE_EXTERNAL_STORAGE: // If request is cancelled, the result arrays are empty. if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Do nothing } else { Toast.makeText(m_act, "App will be unable to save files to external storage", Toast.LENGTH_SHORT) .show(); } break; default: { LogUtil.log("SharedMenu sharedOnRequestPermissionResult UNMANAGED/ERROR requestCode: " + requestCode); for (int i = 0; i < permissions.length; i++) LogUtil.log("SharedMenuUtil permissions: " + permissions[i] + " " + grantResults[i]); } } }
From source file:es.upv.riromu.arbre.main.MainActivity.java
/******************************************/ public void pickImage(View view) { // Do something in response to button click Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, PICK_IMAGE); }
From source file:net.reichholf.dreamdroid.activities.TimerEditActivity.java
/** * // w w w .j a va2 s . com */ private void pickService() { Intent intent = new Intent(this, ServiceListActivity.class); ExtendedHashMap map = new ExtendedHashMap(); map.put(Service.REFERENCE, "default"); intent.putExtra(sData, map); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, PICK_SERVICE_REQUEST); }
From source file:com.example.android.shuttershock.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }/*w ww . j ava2 s . c o m*/ // Handle action buttons switch (item.getItemId()) { case R.id.take_pic: Toast.makeText(getApplicationContext(), "button is working", Toast.LENGTH_LONG).show(); takePic(); //galleryAddPic(); return true; case R.id.upload: /* Intent intentx = new Intent(); intentx.setType("image/*"); intentx.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult( Intent.createChooser(intentx, "Select Picture"), SELECT_PICTURE);*/ final Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, SELECT_PICTURE); //galleryAddPic(); return true; case R.id.look: LongOperation longOperation = new LongOperation(this); longOperation.execute(); // readContacts(); return true; case R.id.action_websearch: // create intent to perform web search for this filter Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, getActionBar().getTitle()); // catch event that there's no activity to handle intent if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } else { Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show(); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:it.polimi.spf.app.fragments.profile.ProfileFragment.java
@Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/*"); intent.putExtra("crop", "true"); intent.putExtra("scale", true); intent.putExtra("outputX", PHOTO_WIDTH); intent.putExtra("outputY", PHOTO_HEIGHT); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("return-data", true); startActivityForResult(intent, ACTIVITY_EDIT_PROFILE_PICTURE_CODE); }
From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_client.ui.activity.ItemListActivity.java
public void takeGallery() { Intent photoLibraryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); photoLibraryIntent.setType("image/*"); startActivityForResult(photoLibraryIntent, ID_GALLERY); }