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.example.multi_ndef.frag_telephone.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_telephone, container, false); fetchContact = (Button) v.findViewById(R.id.fetchTeleContact); numbers = (EditText) v.findViewById(R.id.editTelephone); fetchContact.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent, PICK_NUMBER); }//from w w w .j a v a 2 s.c om }); return v; }
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 ww . j a v a2s . com 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.javielinux.dialogs.SelectImageDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { int title = getArguments().getInt("title"); idUser = getArguments().getLong("id_user"); file = getArguments().getString("file"); return new AlertDialog.Builder(getActivity()).setTitle(title) .setItems(R.array.select_type_image, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 0) { File f = new File(file); if (f.exists()) f.delete();//from w w w. j a v a 2 s .c om Intent intendCapture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intendCapture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); intendCapture.putExtra("return-data", true); getActivity().startActivityForResult(intendCapture, ACTIVITY_CAMERA); } else if (which == 1) { Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Media.CONTENT_TYPE); getActivity().startActivityForResult(i, ACTIVITY_SELECTIMAGE); } } }).create(); }
From source file:org.apache.cordova.contactVcardpicker.ContactVcardPicker.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; if (action.equals("getContactVcard")) { Log.d("customPlugin", " getContactVcard "); Runnable getContactVcard = new Runnable() { @Override/*ww w .j a va 2s . c om*/ public void run() { Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); cordova.setActivityResultCallback(ContactVcardPicker.this); cordova.getActivity().startActivityForResult(contactPickerIntent, 5); } }; this.cordova.getActivity().runOnUiThread(getContactVcard); return true; } else { return false; } }
From source file:com.example.multi_ndef.frag_contact.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.frag_contact, container, false); ma = (CNFCInterface) getActivity().getApplication(); fatchContact = (Button) v.findViewById(R.id.button2); v_name = (EditText) v.findViewById(R.id.editText4); v_number = (EditText) v.findViewById(R.id.editText5); v_mail = (EditText) v.findViewById(R.id.editText6); v_add = (EditText) v.findViewById(R.id.editText7); fatchContact.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent, PICK_CONTACT); }//from w w w .ja va 2s .c o m }); return v; }
From source file:org.telegram.ui.Views.AvatarUpdater.java
public void openGallery() { try {/*from w ww . j ava 2s.c o m*/ Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); if (parentFragment != null) { parentFragment.startActivityForResult(photoPickerIntent, 1); } else if (parentActivity != null) { parentActivity.startActivityForResult(photoPickerIntent, 1); } } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:org.videolan.vlc.gui.browser.FilePickerFragment.java
void pickFile(MediaWrapper mw) { getActivity().setResult(Activity.RESULT_OK, new Intent(Intent.ACTION_PICK, mw.getUri())); getActivity().finish(); }
From source file:com.dd.courier.fragment.RegistFragmentSecond.java
public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); switch (v.getId()) { case R.id.tv_card_front: startActivityForResult(intent, MyConstants.PHOTO_CDRD_FRONT_DATA); break;/*from w w w .j a v a 2s .c o m*/ case R.id.tv_card_rear: startActivityForResult(intent, MyConstants.PHOTO_CDRD_REAR_DATA); break; case R.id.tv_card: startActivityForResult(intent, MyConstants.PHOTO_CDRD_WITH_DATA); break; default: break; } }
From source file:com.github.piasy.rxqrcode.example.QrScanFragment.java
@OnClick(R2.id.mScanFromPicture) public void scanFromPicture() { Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, PICK_IMAGE_RESULT); }
From source file:com.example.dany.jjdraw.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); drawView = (DrawingView) findViewById(R.id.drawing); LinearLayout paintLayout = (LinearLayout) findViewById(R.id.paint_colors); currPaint = (ImageButton) paintLayout.getChildAt(0); currPaint.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable.paint_pressed, null)); smallBrush = getResources().getInteger(R.integer.small_size); mediumBrush = getResources().getInteger(R.integer.medium_size); largeBrush = getResources().getInteger(R.integer.large_size); drawBtn = (ImageButton) findViewById(R.id.draw_btn); drawBtn.setOnClickListener(this); drawView.setBrushSize(mediumBrush);// w w w.j a v a 2s . co m eraseBtn = (ImageButton) findViewById(R.id.erase_btn); eraseBtn.setOnClickListener(this); newBtn = (ImageButton) findViewById(R.id.new_btn); newBtn.setOnClickListener(this); saveBtn = (ImageButton) findViewById(R.id.save_btn); saveBtn.setOnClickListener(this); insertBtn = (ImageButton) findViewById(R.id.insert_btn); insertBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, RESULT_LOAD_IMAGE); } }); undoBtn = (ImageButton) findViewById(R.id.undo_btn); undoBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!drawView.onClickUndo()) { Toast nothingToast = Toast.makeText(getApplicationContext(), "Nothing to Undo!", Toast.LENGTH_SHORT); nothingToast.show(); } } }); redoBtn = (ImageButton) findViewById(R.id.redo_btn); redoBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!drawView.onClickRedo()) { Toast nothingToast = Toast.makeText(getApplicationContext(), "Nothing to Redo!", Toast.LENGTH_SHORT); nothingToast.show(); } } }); }