List of usage examples for android.content Intent EXTRA_MIME_TYPES
String EXTRA_MIME_TYPES
To view the source code for android.content Intent EXTRA_MIME_TYPES.
Click Source Link
From source file:org.strongswan.android.ui.activity.TrustedCertificateImportActivity.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override/*from ww w . j a v a 2s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { /* do nothing when we are restoring */ return; } Intent intent = getIntent(); String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { importCertificate(intent.getData()); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT); openIntent.setType("*/*"); openIntent.putExtra(Intent.EXTRA_MIME_TYPES, ACCEPTED_MIME_TYPES); startActivityForResult(openIntent, OPEN_DOCUMENT); } }
From source file:java_lang_programming.com.android_media_demo.article94.java.ImageDecoderActivity.java
/** * start ExternalApps if the required READ_EXTERNAL_STORAGE permission has been granted. *///ww w.j a v a 2 s . c o m private void startExternalAppSelectableImage() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // Filter to only show results that can be "opened", such as a // file (as opposed to a list of contacts or timezones) intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { intent.putExtra(Intent.EXTRA_MIME_TYPES, types.toArray()); } startActivityForResult(Intent.createChooser(intent, null), ImageSelectionDemoActivity.REQUEST_CODE_CHOOSER); }
From source file:com.farmerbb.notepad.fragment.WelcomeFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override/*from w ww. java 2 s . co m*/ public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_settings: Intent intentSettings = new Intent(getActivity(), SettingsActivity.class); startActivity(intentSettings); return true; case R.id.action_import: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "text/plain", "text/html", "text/x-markdown" }); intent.setType("*/*"); try { getActivity().startActivityForResult(intent, 42); } catch (ActivityNotFoundException e) { showToast(R.string.error_importing_notes); } return true; case R.id.action_about: DialogFragment aboutFragment = new AboutDialogFragment(); aboutFragment.show(getFragmentManager(), "about"); return true; default: return super.onOptionsItemSelected(item); } }
From source file:java_lang_programming.com.android_media_demo.ImageSelectionCropDemo.java
/** * start ExternalApp if the required READ_EXTERNAL_STORAGE permission has been granted. */// w ww. j ava 2s . co m private void startExternalAppSelectableImage() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // Filter to only show results that can be "opened", such as a // file (as opposed to a list of contacts or timezones) intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { intent.putExtra(Intent.EXTRA_MIME_TYPES, types.toArray()); } startActivityForResult(Intent.createChooser(intent, null), ImageSelectionCropDemo.REQUEST_CODE_CHOOSER); }
From source file:com.renard.ocr.BaseDocumentActivitiy.java
protected void startGallery() { cameraPicUri = null;//from w w w. j av a 2 s . co m Intent i = new Intent(Intent.ACTION_GET_CONTENT, null); if (Build.VERSION.SDK_INT >= 19) { i.setType("image/*"); i.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "image/png", "image/jpg", "image/jpeg" }); } else { i.setType("image/png,image/jpg, image/jpeg"); } Intent chooser = Intent.createChooser(i, getString(R.string.image_source)); startActivityForResult(chooser, REQUEST_CODE_PICK_PHOTO); }
From source file:com.example.linhdq.test.documents.creation.NewDocumentActivity.java
protected void startGallery() { cameraPicUri = null;/*from w ww .j a v a2s . com*/ Intent i; if (Build.VERSION.SDK_INT >= 19) { i = new Intent(Intent.ACTION_GET_CONTENT, null); i.addCategory(Intent.CATEGORY_OPENABLE); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); i.setType("image/*"); i.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "image/png", "image/jpg", "image/jpeg" }); } else { i = new Intent(Intent.ACTION_GET_CONTENT, null); i.setType("image/png,image/jpg, image/jpeg"); } Intent chooser = Intent.createChooser(i, this.getResources().getString(R.string.image_source)); try { startActivityForResult(chooser, REQUEST_CODE_PICK_PHOTO); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.no_gallery_found, Toast.LENGTH_LONG).show(); } }
From source file:com.renard.ocr.documents.creation.NewDocumentActivity.java
protected void startGallery() { mAnalytics.startGallery();/*from ww w . j a va 2 s.c o m*/ cameraPicUri = null; Intent i; if (Build.VERSION.SDK_INT >= 19) { i = new Intent(Intent.ACTION_GET_CONTENT, null); i.addCategory(Intent.CATEGORY_OPENABLE); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); i.setType("image/*"); i.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "image/png", "image/jpg", "image/jpeg" }); } else { i = new Intent(Intent.ACTION_GET_CONTENT, null); i.setType("image/png,image/jpg, image/jpeg"); } Intent chooser = Intent.createChooser(i, getString(R.string.image_source)); try { startActivityForResult(chooser, REQUEST_CODE_PICK_PHOTO); } catch (ActivityNotFoundException e) { Toast.makeText(this, R.string.no_gallery_found, Toast.LENGTH_LONG).show(); } }
From source file:com.android.messaging.ui.UIIntentsImpl.java
@Override public void launchDocumentImagePicker(final Fragment fragment) { final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.putExtra(Intent.EXTRA_MIME_TYPES, MessagePartData.ACCEPTABLE_IMAGE_TYPES); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType(ContentType.IMAGE_UNSPECIFIED); fragment.startActivityForResult(intent, REQUEST_PICK_IMAGE_FROM_DOCUMENT_PICKER); }
From source file:com.android.documentsui.DocumentsActivity.java
private void buildDefaultState() { mState = new State(); final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) { mState.action = ACTION_OPEN;// w w w . ja v a 2 s.co m } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); } if (mState.action == ACTION_MANAGE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES); } else { mState.acceptMimes = new String[] { intent.getType() }; } mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false); mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this); }
From source file:com.farmerbb.notepad.fragment.NoteListFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override//from w ww .j a v a2 s. c o m public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_start_selection: listener.startMultiSelect(); return true; case R.id.action_settings: Intent intentSettings = new Intent(getActivity(), SettingsActivity.class); startActivity(intentSettings); return true; case R.id.action_import: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "text/plain", "text/html", "text/x-markdown" }); intent.setType("*/*"); try { getActivity().startActivityForResult(intent, MainActivity.IMPORT); } catch (ActivityNotFoundException e) { showToast(R.string.error_importing_notes); } return true; case R.id.action_about: DialogFragment aboutFragment = new AboutDialogFragment(); aboutFragment.show(getFragmentManager(), "about"); return true; default: return super.onOptionsItemSelected(item); } }