List of usage examples for android.content Intent ACTION_OPEN_DOCUMENT
String ACTION_OPEN_DOCUMENT
To view the source code for android.content Intent ACTION_OPEN_DOCUMENT.
Click Source Link
From source file:edu.sfsu.csc780.chathub.ui.activities.MainActivity.java
private void pickImage() { // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file browser Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); // Filter to only show results that can be "opened" intent.addCategory(Intent.CATEGORY_OPENABLE); // Filter to show only images, using the image MIME data type. intent.setType("image/*"); startActivityForResult(intent, REQUEST_PICK_IMAGE); }
From source file:com.example.android.pharmacyinventory.EditorActivity.java
public void openImageSelector() { Intent intent;//from ww w.j a v a 2 s. co m if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); }
From source file:com.github.mjdev.libaums.usbfileman.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.create_file: new NewFileDialog().show(getFragmentManager(), "NEW_FILE"); return true; case R.id.create_dir: new NewDirDialog().show(getFragmentManager(), "NEW_DIR"); return true; case R.id.create_big_file: createBigFile();//from www . j a va 2 s . co m return true; case R.id.paste: move(); return true; case R.id.stop_http_server: if (serverService != null) { serverService.stopServer(); } return true; case R.id.run_tests: startActivity(new Intent(this, LibAumsTest.class)); return true; case R.id.open_storage_provider: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (device != null) { Log.d(TAG, "Closing device first"); device.close(); } Intent intent = new Intent(); intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); String[] extraMimeTypes = { "image/*", "video/*" }; intent.putExtra(Intent.EXTRA_MIME_TYPES, extraMimeTypes); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(intent, OPEN_STORAGE_PROVIDER_RESULT); } return true; case R.id.copy_from_storage_provider: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); startActivityForResult(intent, COPY_STORAGE_PROVIDER_RESULT); } return true; default: return super.onOptionsItemSelected(item); } }
From source file:uno.weichen.abnd10_inventoryapp.DetailActivity.java
public void openImageSelector(View view) { Intent intent;/* w w w. j av a2 s . com*/ if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
private void startFileChooser() { final Intent importIntent; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) importIntent = new Intent(Intent.ACTION_GET_CONTENT); else/*from w w w .j a v a2s .co m*/ importIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); importIntent.setType("*/*"); importIntent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(importIntent, getResources().getText(R.string.action_import)), ACTIVITY_REQUEST_CODE_IMPORT); }
From source file:jackpal.androidterm.TermPreferences.java
private void doFilePicker() { AlertDialog.Builder bld = new AlertDialog.Builder(this); bld.setIcon(android.R.drawable.ic_dialog_info); bld.setMessage(this.getString(R.string.font_file_error)); bld.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss();//from w w w .ja v a2 s . c o m Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("application/octet-stream"); startActivityForResult(intent, REQUEST_FONT_PICKER); } }); bld.setNegativeButton(this.getString(android.R.string.no), null); final Activity activity = this; bld.setNeutralButton(this.getString(R.string.entry_fontfile_default), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity); sp.edit().putString(FONT_FILENAME, activity.getString(R.string.entry_fontfile_default)) .apply(); } }); bld.create().show(); }
From source file:us.theparamountgroup.android.inventory.EditorActivity.java
public void openImageSelector(View view) { Intent intent;/*from www. j av a 2 s . c om*/ Log.e(LOG_TAG, "While is set and the ifs are worked through."); if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } Log.e(LOG_TAG, "Check write to external permissions"); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); }
From source file:org.kontalk.ui.AbstractComposeFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) private Intent createGalleryIntent(boolean useSAF) { Intent intent;//from ww w . j av a2 s . c o m if (!useSAF) { intent = SystemUtils.externalIntent(Intent.ACTION_GET_CONTENT) .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { intent = SystemUtils.externalIntent(Intent.ACTION_OPEN_DOCUMENT); } return intent.addCategory(Intent.CATEGORY_OPENABLE).setType("image/*") .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }
From source file:org.kontalk.ui.ComposeMessageFragment.java
/** Starts an activity for picture attachment selection. */ @TargetApi(Build.VERSION_CODES.KITKAT)//from ww w . j ava2s .c o m private void selectGalleryAttachment() { Intent pictureIntent; if (!MediaStorage.isStorageAccessFrameworkAvailable()) { pictureIntent = new Intent(Intent.ACTION_GET_CONTENT).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { pictureIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } pictureIntent.addCategory(Intent.CATEGORY_OPENABLE).setType("image/*") .addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION).putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(pictureIntent, SELECT_ATTACHMENT_OPENABLE); }
From source file:com.apptentive.android.sdk.module.engagement.interaction.fragment.MessageCenterFragment.java
@Override public void onAttachImage() { try {// www . j a v a 2s . c om if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {//prior Api level 19 Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); Intent chooserIntent = Intent.createChooser(intent, null); startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); Intent chooserIntent = Intent.createChooser(intent, null); startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } imagePickerStillOpen = true; } catch (Exception e) { e.printStackTrace(); imagePickerStillOpen = false; ApptentiveLog.d("can't launch image picker"); } }