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.odk.collect.android.activities.FormChooserList.java
/** * Stores the path of selected form and finishes. *///www . j av a 2 s .c o m @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (Collect.allowClick(getClass().getName())) { // get uri to form long idFormsTable = listView.getAdapter().getItemId(position); Uri formUri = ContentUris.withAppendedId(FormsColumns.CONTENT_URI, idFormsTable); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action)) { // caller is waiting on a picked form setResult(RESULT_OK, new Intent().setData(formUri)); } else { // caller wants to view/edit a form, so launch formentryactivity Intent intent = new Intent(Intent.ACTION_EDIT, formUri); intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.EDIT_SAVED); startActivity(intent); } finish(); } }
From source file:com.duy.ascii.sharedcode.image.ImageToAsciiActivity.java
private void selectImage() { if (!permissionGrated()) { return;//from w w w . j a va2 s . c o m } Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT); getIntent.setType("image/*"); Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickIntent.setType("image/*"); Intent chooserIntent = Intent.createChooser(getIntent, "Select Image"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { pickIntent }); startActivityForResult(chooserIntent, PICK_IMAGE); }
From source file:com.jcedar.tixee.activity.ScanTicketActivity.java
@Override public void onClick(View view) { switch (view.getId()) { case R.id.btScanTicketCamera: ActivityCompat.requestPermissions(ScanTicketActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_WRITE_PERMISSION); break;/*from w ww .java 2s. c om*/ case R.id.btScanTicketGallery: //launch gallery via intent Intent photoPic = new Intent(Intent.ACTION_PICK); photoPic.setType("image/*"); startActivityForResult(photoPic, SELECT_PHOTO); break; case R.id.btScanResultVerify: if (!MyUtils.checkNetworkAvailability(this)) { MyUtils.networkDialog(this).show(); } else if ((scanResultString.contains("&")) || (scanResultString.contains("?")) || (scanResultString.contains("/"))) { Toast.makeText(this, "This is not a valid Ticket", Toast.LENGTH_SHORT).show(); } else fetchTicketDetails(scanResultString); } }
From source file:com.ferid.app.frequentcontacts.MainActivity.java
/** * Select a photo from the gallery//from w w w .j a va 2 s . c o m */ private void selectPhoto() { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, RESULT_LOAD_IMAGE); }
From source file:org.thoughtcrime.securesms.contacts.ContactAccessorNewApi.java
@Override public Intent getIntentForContactSelection() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); return intent; }
From source file:stepic.stepic.BaseMapsActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getLayoutId());//from ww w. ja va2 s . c o m setUpMap(); Intent camIntent = new Intent("android.media.action.IMAGE_CAPTURE"); Intent gallIntent = new Intent(Intent.ACTION_GET_CONTENT); gallIntent.setType("image/*"); info = new ArrayList<ResolveInfo>(); yourIntentsList = new ArrayList<Intent>(); PackageManager packageManager = BaseMapsActivity.this.getPackageManager(); List<ResolveInfo> listCam = packageManager.queryIntentActivities(camIntent, 0); for (ResolveInfo res : listCam) { final Intent finalIntent = new Intent(camIntent); finalIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); yourIntentsList.add(finalIntent); info.add(res); } List<ResolveInfo> listGall = packageManager.queryIntentActivities(gallIntent, 0); for (ResolveInfo res : listGall) { final Intent finalIntent = new Intent(gallIntent); finalIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); yourIntentsList.add(finalIntent); info.add(res); } // android.support.v7.app.ActionBar actionBar = getSupportActionBar(); // actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff"))); // actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff"))); //Navigation Drawer Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Drawable drawable = ContextCompat.getDrawable(getApplicationContext(), R.drawable.add); toolbar.setOverflowIcon(drawable); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); mHandler = new Handler(); Button add = (Button) findViewById(R.id.add); add.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent tmp = new Intent(Intent.ACTION_PICK); tmp.setType(android.provider.MediaStore.Images.Media.CONTENT_TYPE); startActivityForResult(tmp, PICK_FROM_ALBUM); } }); // runOnUiThread(new Runnable() { // @Override // public void run() { // mProgressDialog = ProgressDialog.show(BaseMapsActivity.this, "", " .", true); // mHandler.postDelayed(new Runnable() { // @Override // public void run() { // try { // if (mProgressDialog != null && mProgressDialog.isShowing()) { // mProgressDialog.dismiss(); // } // } catch (Exception e) { // e.printStackTrace(); // } // } // }, 1000); // } // // }); }
From source file:ca.uwaterloo.magic.goodhikes.ProfileActivity.java
private void uploadProfileImage() { // Create intent to Open Image applications like Gallery, Google Photos Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, FROM_GALLERY); }
From source file:com.cmput301w15t15.travelclaimsapp.activitys.EditExpenseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.edit_expense); sdf = new SimpleDateFormat("MM/dd/yyyy", Locale.CANADA); expenseName = this.getIntent().getExtras().getString("expenseName"); claimName = this.getIntent().getExtras().getString("claimName"); date = (EditText) findViewById(R.id.Edit_Expense_Date2); expenseNameInput = (EditText) findViewById(R.id.Edit_Expense_Name2); expenseCostInput = (EditText) findViewById(R.id.Edit_Expense_Cost2); expenseDescriptionInput = (EditText) findViewById(R.id.Edit_Expense_Description2); currencySpinner = (Spinner) findViewById(R.id.CurrencySpinner2); categorySpinner = (Spinner) findViewById(R.id.CategorySpinner2); expenseReceiptView = (ImageView) findViewById(R.id.Edit_Expense_Image2); claimList = ClaimListController.getClaimList(); claim = claimList.getClaim(claimName); expenseList = claim.getExpenseList(); expense = expenseList.getExpense(expenseName); // show initial image if (expense.getPicture() != null) { imgShow = expense.getPicture();/*w w w .j a v a 2 s .com*/ Bitmap bm = BitmapFactory.decodeByteArray(imgShow, 0, imgShow.length); sizeNum = imgShow.length; size = sizeNum.toString(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); expenseReceiptView.setMinimumHeight(dm.heightPixels); expenseReceiptView.setMinimumWidth(dm.widthPixels); expenseReceiptView.setImageBitmap(bm); } expenseReceiptView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { // Create the Intent for Image Gallery. Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); // Start new activity with the LOAD_IMAGE_RESULTS to handle back the results when image is picked from the Image Gallery. startActivityForResult(i, 1); return true; } }); expenseReceiptView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { loadPhoto((ImageView) v, 100, 100); } }); currencySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { expense.setCurr(parent.getItemAtPosition(position).toString()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { expense.setCat(parent.getItemAtPosition(position).toString()); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); set_on_click(); }
From source file:ca.uwaterloo.magic.goodhikes.AddMilestoneDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { mapsActivity = (MapsActivity) getActivity(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = getActivity().getLayoutInflater(); View dialog = inflater.inflate(R.layout.dialog_add_milestone, null); previewImage = (ImageView) dialog.findViewById(R.id.previewImage); if (savedInstanceState != null) { Bitmap image = savedInstanceState.getParcelable("image"); if (image != null) { previewImage.setImageBitmap(image); }//from ww w.j a v a 2s .co m } builder.setView(dialog).setTitle(R.string.add_milestone) .setPositiveButton(R.string.add, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { EditText noteField = (EditText) ((Dialog) dialog).findViewById(R.id.note); String note = noteField.getText().toString(); Bitmap image = previewImage.getDrawable() == null ? null : ((BitmapDrawable) previewImage.getDrawable()).getBitmap(); mapsActivity.imageSelected(image, note); Toast.makeText(getActivity(), "Milestone added", Toast.LENGTH_SHORT).show(); Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; milestone added"); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; milestone cancelled"); } }); Button addImageButton = (Button) dialog.findViewById(R.id.addImageButton); addImageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create intent to Open Image applications like Gallery, Google Photos Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, RESULT_LOAD_IMG); } }); Button cameraButton = (Button) dialog.findViewById(R.id.cameraButton); cameraButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Create intent to open device's Camera Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, RESULT_CAPTURE_IMG); } }); return builder.create(); }
From source file:com.wishlist.Wishlist.java
/** Called when the activity is first created. */ @Override//from w w w.ja v a2s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see FbAPIs.java"); return; } setContentView(R.layout.wishlist); mHandler = new Handler(); mText = (TextView) Wishlist.this.findViewById(R.id.txt); mUserPic = (ImageView) Wishlist.this.findViewById(R.id.user_pic); mProduceName = (EditText) Wishlist.this.findViewById(R.id.product_name); mWishlistSpinner = (Spinner) Wishlist.this.findViewById(R.id.wishlist_spinner); mPlacesListSpinner = (Spinner) Wishlist.this.findViewById(R.id.location); image = (ImageView) Wishlist.this.findViewById(R.id.itemPhoto); image.setImageResource(R.drawable.camera); image.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK, (MediaStore.Images.Media.EXTERNAL_CONTENT_URI)); startActivityForResult(intent, PICK_EXISTING_PHOTO_RESULT_CODE); } }); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.wishlist_array, android.R.layout.simple_spinner_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mWishlistSpinner.setAdapter(adapter); mPlacesListSpinner.setClickable(false); mAddtoTimeline = (Button) Wishlist.this.findViewById(R.id.timeline); mAddtoTimeline.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!Utility.mFacebook.isSessionValid()) { showToast(getString(R.string.must_login)); return; } mProductName = mProduceName.getText().toString(); if (mProductName == null || TextUtils.isEmpty(mProductName)) { showToast(getString(R.string.enter_product_name)); return; } if (imageBytes == null) { showToast(getString(R.string.take_product_photo)); return; } /* * Upload photo first and then publish to the timeline after successful photo upload. */ uploadPhoto(); } }); /* * Initalize Facebook Object, retrieve access token and layout the Login button */ initFacebook(); }