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:com.brandroidtools.filemanager.activities.PickerActivity.java
private boolean isDirectoryPickIntent(Intent intent) { if (Intent.ACTION_PICK.equals(intent.getAction()) && intent.getData() != null) { String scheme = intent.getData().getScheme(); if (FOLDER_URI_SCHEME.equals(scheme) || DIRECTORY_URI_SCHEME.equals(scheme)) { return true; }/*w w w . j ava2 s.co m*/ } return false; }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageActivity.java
public void onBrowseForNumbersButtonClicked() { Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); startActivityForResult(contactPickerIntent, REQUEST_CONTACT_NUMBER); }
From source file:info.papdt.blacklight.ui.statuses.NewPostActivity.java
private void showPicturePicker() { new AlertDialog.Builder(this).setItems(getResources().getStringArray(R.array.picture_picker_array), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int id) { switch (id) { case 0: Intent i = new Intent(); if (Build.VERSION.SDK_INT >= 19) { i.setAction(Intent.ACTION_OPEN_DOCUMENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); } else { i.setAction(Intent.ACTION_PICK); i.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); }// w w w . j a va2s. com startActivityForResult(i, REQUEST_PICK_IMG); break; case 1: Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri uri = Utility.getOutputMediaFileUri(); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(captureIntent, REQUEST_CAPTURE_PHOTO); break; case 2: Intent multi = new Intent(); multi.setAction("us.shandian.blacklight.MULTI_PICK"); multi.setClass(NewPostActivity.this, MultiPicturePicker.class); startActivityForResult(multi, 1000); break; } } }).show(); }
From source file:com.soomla.example.ExampleSocialActivity.java
private void chooseImageFile() { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, SELECT_PHOTO_ACTION); }
From source file:com.ushahidi.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog/* w w w. j a va2s .c o m*/ */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddReportActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_MULTIPLE_CATEGORY: { if (showCategories() != null) { return new AlertDialog.Builder(this).setTitle(R.string.choose_categories) .setMultiChoiceItems(showCategories(), setCheckedCategories(), new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { // see if categories have previously if (isChecked) { mVectorCategories.add(mCategoriesId.get(whichButton)); mError = false; } else { mVectorCategories.remove(mCategoriesId.get(whichButton)); } setSelectedCategories(mVectorCategories); } }) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Yes so do some stuff */ } }).create(); } } case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), false); case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete report deleteReport(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:net.reichholf.dreamdroid.fragment.TimerEditFragment.java
/** * *//*from w ww. j av a 2 s . c o m*/ private void pickService() { ServiceListFragment f = new ServiceListFragment(); Bundle args = new Bundle(); ExtendedHashMap data = new ExtendedHashMap(); data.put(Service.KEY_REFERENCE, "default"); args.putSerializable(sData, data); args.putString("action", Intent.ACTION_PICK); f.setArguments(args); f.setTargetFragment(this, Statics.REQUEST_PICK_SERVICE); ((MultiPaneHandler) getAppCompatActivity()).showDetails(f, true); }
From source file:com.brandroidtools.filemanager.activities.PickerActivity.java
private File getInitialDirectoryFromIntent(Intent intent) { if (!Intent.ACTION_PICK.equals(intent.getAction())) { return null; }/*from w ww .ja va2 s . co m*/ final Uri data = intent.getData(); if (data == null) { return null; } final String path = data.getPath(); if (path == null) { return null; } final File file = new File(path); if (!file.exists() || !file.isAbsolute()) { return null; } if (file.isDirectory()) { return file; } return file.getParentFile(); }
From source file:cn.zsmy.akm.doctor.profile.fragment.DoctorLicenseFragment.java
@Override public void onItemClick(int position) { switch (position) { case 0://from w ww . ja v a 2 s .c o m PHOTO_CREAME = CREAME; Intent openCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + String.valueOf(System.currentTimeMillis()) + ".jpg"); tempUri = Uri.fromFile(file); openCameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, tempUri); startActivityForResult(openCameraIntent, PIC); break; case 1: PHOTO_CREAME = PHOTO; Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, PIC); break; } WHETHER_FROM_ACTIVITY_BACK = true; }
From source file:com.example.zf_android.activity.MerchantEdit.java
private void show2Dialog(int type) { AlertDialog.Builder builder = new AlertDialog.Builder(MerchantEdit.this); final String[] items = getResources().getStringArray(R.array.apply_detail_upload); MerchantEdit.this.type = type; builder.setItems(items, new DialogInterface.OnClickListener() { @Override/* w w w . ja va 2s. c o m*/ public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_UPLOAD_IMAGE); break; } case 1: { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File outDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (!outDir.exists()) { outDir.mkdirs(); } File outFile = new File(outDir, System.currentTimeMillis() + ".jpg"); photoPath = outFile.getAbsolutePath(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile)); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(intent, REQUEST_TAKE_PHOTO); } else { CommonUtil.toastShort(MerchantEdit.this, getString(R.string.toast_no_sdcard)); } break; } } } }); builder.show(); }
From source file:br.com.GUI.avaliacoes.AvaliarPerimetria.java
public void usarGaleria() { Calendar c = Calendar.getInstance(); FILE_NAME = c.get(Calendar.DAY_OF_MONTH) + "_" + c.get(Calendar.YEAR) + ".jpg"; Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { photo = new File(android.os.Environment.getExternalStorageDirectory(), FILE_NAME); } else {//from w ww . j av a 2 s .c om photo = new File(getActivity().getCacheDir(), FILE_NAME); } if (photo != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); selectedImageUri = Uri.fromFile(photo); startActivityForResult(intent, 200); } }