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:net.coding.program.project.init.create.ProjectCreateFragment.java
private void photo() { Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, RESULT_REQUEST_PHOTO); }
From source file:com.intel.xdk.contacts.Contacts.java
public void chooseContact() { try {/* w ww .jav a 2 s . com*/ if (busy == true) { String js = "javascript: var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.busy',true,true);e.success=false;e.message='busy';document.dispatchEvent(e);"; injectJS(js); return; } busy = true; Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); cordova.setActivityResultCallback(this); activity.startActivityForResult(intent, CONTACT_CHOOSER_RESULT); //activity.setLaunchedChildActivity(true); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.odk.collect.android.activities.InstanceChooserList.java
/** * Stores the path of selected instance in the parent class and finishes. *///from w w w . j a v a 2 s. c o m @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (Collect.allowClick(getClass().getName())) { if (view.isEnabled()) { Cursor c = (Cursor) listView.getAdapter().getItem(position); Uri instanceUri = ContentUris.withAppendedId(InstanceColumns.CONTENT_URI, c.getLong(c.getColumnIndex(InstanceColumns._ID))); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action)) { // caller is waiting on a picked form setResult(RESULT_OK, new Intent().setData(instanceUri)); } else { // the form can be edited if it is incomplete or if, when it was // marked as complete, it was determined that it could be edited // later. String status = c.getString(c.getColumnIndex(InstanceColumns.STATUS)); String strCanEditWhenComplete = c .getString(c.getColumnIndex(InstanceColumns.CAN_EDIT_WHEN_COMPLETE)); boolean canEdit = status.equals(InstanceProviderAPI.STATUS_INCOMPLETE) || Boolean.parseBoolean(strCanEditWhenComplete); if (!canEdit) { createErrorDialog(getString(R.string.cannot_edit_completed_form), DO_NOT_EXIT); return; } // caller wants to view/edit a form, so launch formentryactivity Intent parentIntent = this.getIntent(); Intent intent = new Intent(Intent.ACTION_EDIT, instanceUri); String formMode = parentIntent.getStringExtra(ApplicationConstants.BundleKeys.FORM_MODE); if (formMode == null || ApplicationConstants.FormModes.EDIT_SAVED.equalsIgnoreCase(formMode)) { intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.EDIT_SAVED); } else { intent.putExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.VIEW_SENT); } startActivity(intent); } finish(); } else { TextView disabledCause = view.findViewById(R.id.form_subtitle2); Toast.makeText(this, disabledCause.getText(), Toast.LENGTH_SHORT).show(); } } }
From source file:com.trellmor.mocklocationpicture.MLPActivity.java
private void load() { clear();/*from w w w.jav a2 s . c o m*/ Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI); startActivityForResult(intent, ACTIVITY_SELECT_IMAGE); }
From source file:com.kbeanie.imagechooser.api.MediaChooserManager.java
private void chooseMedia() throws ChooserException { checkDirectory();/* w w w. ja v a 2 s . c o m*/ try { Intent intent = new Intent(Intent.ACTION_PICK); if (extras != null) { intent.putExtras(extras); } intent.setType("video/*, image/*"); startActivity(intent); } catch (ActivityNotFoundException e) { throw new ChooserException(e); } }
From source file:com.pacoapp.paco.ui.FindExperimentsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.debug("FindExperimentsActivity onCreate"); mainLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.find_experiments, null); setContentView(mainLayout);/*ww w .j a va 2 s .c o m*/ ActionBar actionBar = getSupportActionBar(); actionBar.setLogo(R.drawable.ic_launcher); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayShowHomeEnabled(true); actionBar.setBackgroundDrawable(new ColorDrawable(0xff4A53B3)); actionBar.setDisplayHomeAsUpEnabled(true); // Set up the drawer. // mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); // mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); Intent intent = getIntent(); userPrefs = new UserPreferences(this); list = (ListView) findViewById(R.id.find_experiments_list); // createListHeader(); // createRefreshHeader(); experimentProviderUtil = new ExperimentProviderUtil(this); progressBar = (ProgressBar) findViewById(R.id.findExperimentsProgressBar); reloadAdapter(); list.setItemsCanFocus(true); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listview, View textview, int position, long id) { Experiment experiment = experiments.get(position); getIntent().putExtra(Experiment.EXPERIMENT_SERVER_ID_EXTRA_KEY, experiment.getServerId()); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) { // The caller is waiting for us to return an experiment selected by // the user. The have clicked on one, so return it now. Intent resultIntent = new Intent(); resultIntent.putExtra(Experiment.EXPERIMENT_SERVER_ID_EXTRA_KEY, experiment.getServerId()); setResult(RESULT_OK, resultIntent); } else { Intent experimentIntent = new Intent(FindExperimentsActivity.this, ExperimentDetailActivity.class); experimentIntent.putExtra(Experiment.EXPERIMENT_SERVER_ID_EXTRA_KEY, experiment.getServerId()); experimentIntent.putExtra(ExperimentDetailActivity.ID_FROM_MY_EXPERIMENTS_FILE, false); startActivityForResult(experimentIntent, JOIN_REQUEST_CODE); } } }); registerForContextMenu(list); }
From source file:org.apache.cordova.contacts.ContactManager.java
/** * Launches the Contact Picker to select a single contact. *//* w w w . j av a2 s . c o m*/ 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); }
From source file:com.amytech.android.library.views.imagechooser.api.MediaChooserManager.java
private void chooseMedia() throws Exception { checkDirectory();//from w w w . j av a 2 s .c o m try { Intent intent = new Intent(Intent.ACTION_PICK); if (extras != null) { intent.putExtras(extras); } intent.setType("video/*, image/*"); startActivity(intent); } catch (ActivityNotFoundException e) { throw new Exception("Activity not found"); } }
From source file:net.exclaimindustries.geohashdroid.wiki.WikiPictureEditor.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Get some display metrics. We need to scale the gallery thumbnails // accordingly, else they look too small on big screens and too big on // small screens. We do this here to save calculations later, else // we'd be doing floating-point multiplication on EVERY SINGLE // THUMBNAIL, and we can't guarantee that won't be painful on every // Android phone. DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); THUMB_DIMEN = (int) (getResources().getDimensionPixelSize(R.dimen.nominal_icon_size) * metrics.density); Log.d(DEBUG_TAG, "Thumbnail dimensions: " + THUMB_DIMEN); mInfo = (Info) getIntent().getParcelableExtra(GeohashDroid.INFO); setContentView(R.layout.pictureselect); Button submitButton = (Button) findViewById(R.id.wikieditbutton); ImageButton galleryButton = (ImageButton) findViewById(R.id.GalleryButton); galleryButton.setOnClickListener(new View.OnClickListener() { @Override//from w ww. j a va2 s.c om public void onClick(View v) { // Fire off the Gallery! startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI), REQUEST_PICTURE); } }); submitButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // We don't want to let the Activity handle the dialog. That WILL // cause it to show up properly and all, but after a configuration // change (i.e. orientation shift), it won't show or update any text // (as far as I know), as we can't reassign the handler properly. // So, we'll handle it ourselves. mProgress = ProgressDialog.show(WikiPictureEditor.this, "", "", true, true, WikiPictureEditor.this); mConnectionHandler = new PictureConnectionRunner(mProgressHandler, WikiPictureEditor.this); mWikiConnectionThread = new Thread(mConnectionHandler, "WikiConnectionThread"); mWikiConnectionThread.start(); } }); // We can set the background on the thumbnail view right away, even if // it's not actually visible. ImageView thumbView = (ImageView) findViewById(R.id.ThumbnailImage); thumbView.setBackgroundResource(R.drawable.gallery_selected_default); thumbView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); // Now, let's see if we have anything retained... try { RetainedThings retain = (RetainedThings) getLastNonConfigurationInstance(); if (retain != null) { // We have something retained! Thus, we need to construct the // popup and update it with the right status, assuming the // thread's still going. if (retain.thread != null && retain.thread.isAlive()) { mProgress = ProgressDialog.show(WikiPictureEditor.this, "", "", true, true, WikiPictureEditor.this); mConnectionHandler = retain.handler; mConnectionHandler.resetHandler(mProgressHandler); mWikiConnectionThread = retain.thread; } // And in any event, put the image info back up. mCurrentFile = retain.currentFile; mCurrentThumbnail = retain.thumbnail; mPictureLocation = retain.picLocation; setThumbnail(); } else { // If there was nothing to retain, maybe we've got a bundle. if (icicle != null) { if (icicle.containsKey(STORED_FILE)) mCurrentFile = icicle.getString(STORED_FILE); if (icicle.containsKey(STORED_LOCATION)) mPictureLocation = icicle.getParcelable(STORED_LOCATION); } // Rebuild it all in any event. buildThumbnail(); setThumbnail(); } } catch (Exception ex) { // If we got an exception, reset the thumbnail info with whatever // we have handy. buildThumbnail(); setThumbnail(); } // Rebuild the thumbnail and display it as need be. }
From source file:com.pacoapp.paco.ui.FindMyExperimentsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.debug("FindMyExperimentsActivity onCreate"); mainLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.find_experiments, null); setContentView(mainLayout);/*from w w w . j av a 2s .com*/ ActionBar actionBar = getSupportActionBar(); actionBar.setLogo(R.drawable.ic_launcher); actionBar.setDisplayUseLogoEnabled(true); actionBar.setDisplayShowHomeEnabled(true); actionBar.setBackgroundDrawable(new ColorDrawable(0xff4A53B3)); actionBar.setDisplayHomeAsUpEnabled(true); Intent intent = getIntent(); if (intent.getData() == null) { intent.setData(ExperimentColumns.CONTENT_URI); } // Set up the drawer. // mNavigationDrawerFragment = (NavigationDrawerFragment) // getSupportFragmentManager().findFragmentById(R.id.navigation_drawer); // mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) // findViewById(R.id.drawer_layout)); userPrefs = new UserPreferences(this); list = (ListView) findViewById(R.id.find_experiments_list); // createListHeader(); // createRefreshHeader(); experimentProviderUtil = new ExperimentProviderUtil(this); progressBar = (ProgressBar) findViewById(R.id.findExperimentsProgressBar); reloadAdapter(); list.setItemsCanFocus(false); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listview, View textview, int position, long id) { Experiment experiment = experiments.get(position); getIntent().putExtra(Experiment.EXPERIMENT_SERVER_ID_EXTRA_KEY, experiment.getServerId()); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) { // The caller is waiting for us to return an experiment selected by // the user. The have clicked on one, so return it now. Intent resultIntent = new Intent(); resultIntent.putExtra(Experiment.EXPERIMENT_SERVER_ID_EXTRA_KEY, experiment.getServerId()); setResult(RESULT_OK, resultIntent); } else { Intent experimentIntent = new Intent(FindMyExperimentsActivity.this, ExperimentDetailActivity.class); experimentIntent.putExtra(Experiment.EXPERIMENT_SERVER_ID_EXTRA_KEY, experiment.getServerId()); experimentIntent.putExtra(ExperimentDetailActivity.ID_FROM_MY_EXPERIMENTS_FILE, true); startActivityForResult(experimentIntent, JOIN_REQUEST_CODE); } } }); // registerForContextMenu(list); }