Java Code Examples for android.content.Intent#ACTION_CHOOSER
The following examples show how to use
android.content.Intent#ACTION_CHOOSER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Web3WebviewModule.java From react-native-web3-webview with MIT License | 6 votes |
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) public boolean startPhotoPickerIntent(final ValueCallback<Uri[]> callback, final Intent intent, final String[] acceptTypes, final boolean allowMultiple) { filePathCallback = callback; ArrayList<Parcelable> extraIntents = new ArrayList<>(); if (acceptsImages(acceptTypes)) { extraIntents.add(getPhotoIntent()); } if (acceptsVideo(acceptTypes)) { extraIntents.add(getVideoIntent()); } Intent fileSelectionIntent = getFileChooserIntent(acceptTypes, allowMultiple); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, fileSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents.toArray(new Parcelable[]{})); if (chooserIntent.resolveActivity(getCurrentActivity().getPackageManager()) != null) { getCurrentActivity().startActivityForResult(chooserIntent, PICKER); } else { Log.w("Web3WevbiewModule", "there is no Activity to handle this Intent"); } return true; }
Example 2
Source File: ShareTestCase.java From react-native-GPay with MIT License | 6 votes |
public void testShowBasicShareDialog() { final WritableMap content = new WritableNativeMap(); content.putString("message", "Hello, ReactNative!"); final WritableMap options = new WritableNativeMap(); IntentFilter intentFilter = new IntentFilter(Intent.ACTION_CHOOSER); intentFilter.addCategory(Intent.CATEGORY_DEFAULT); ActivityMonitor monitor = getInstrumentation().addMonitor(intentFilter, null, true); getTestModule().showShareDialog(content, options); waitForBridgeAndUIIdle(); getInstrumentation().waitForIdleSync(); assertEquals(1, monitor.getHits()); assertEquals(1, mRecordingModule.getOpened()); assertEquals(0, mRecordingModule.getErrors()); }
Example 3
Source File: ShareHelper.java From ratebeer with GNU General Public License v3.0 | 6 votes |
private void shareLink(String name, String url) { Intent openIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); List<Intent> browserIntents = new ArrayList<>(); for (ResolveInfo openInfo : context.getPackageManager().queryIntentActivities(openIntent, 0)) { if (!openInfo.activityInfo.packageName.equals(BuildConfig.APPLICATION_ID)) { Intent browserIntent = new Intent(); browserIntent.setComponent(new ComponentName(openInfo.activityInfo.packageName, openInfo.activityInfo.name)); browserIntent.setAction(Intent.ACTION_VIEW); browserIntent.setData(Uri.parse(url)); browserIntents.add(browserIntent); } } String shareText = context.getString(R.string.app_sharetext, name, url); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, shareText); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, shareIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, context.getString(R.string.app_openorshare)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, browserIntents.toArray(new Intent[browserIntents.size()])); context.startActivity(chooserIntent); }
Example 4
Source File: MagnetWebChromeClient.java From magnet-client with Mozilla Public License 2.0 | 5 votes |
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { Log.d(TAG, "on show file chooser"); // make sure there is no existing message if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); mFilePathCallback = null; } mFilePathCallback = filePathCallback; // file picker Intent fileChooserIntent = fileChooserParams.createIntent(); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, fileChooserIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); // camera Intent takePictureIntent = createTakePictureIntent(); if (takePictureIntent != null) { Intent[] intentArray = new Intent[]{takePictureIntent}; chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); } try { mReactContext.startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE, null); } catch(Exception err) { Log.d(TAG, err.toString()); return false; } return true; }
Example 5
Source File: MyWebChromeClient.java From CloudReader with Apache License 2.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); mActivity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5); }
Example 6
Source File: MyWebChromeClient.java From ByWebView with Apache License 2.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); mIWebPageView.startFileChooserForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5); }
Example 7
Source File: MyX5WebChromeClient.java From ByWebView with Apache License 2.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); mIWebPageView.startFileChooserForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5); }
Example 8
Source File: ByWebChromeClient.java From ByWebView with Apache License 2.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { Activity mActivity = this.mActivityWeakReference.get(); if (mActivity != null && !mActivity.isFinishing()) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); mActivity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5); } }
Example 9
Source File: WebViewActivity.java From mattermost-android-classic with Apache License 2.0 | 5 votes |
private Intent createChooserIntent(Intent... intents) { Intent chooser = new Intent(Intent.ACTION_CHOOSER); chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intents); chooser.putExtra(Intent.EXTRA_TITLE, mController.getActivity().getResources() .getString(R.string.choose_upload)); return chooser; }
Example 10
Source File: ProgressWebView.java From Android-Application-ZJB with Apache License 2.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); Activity activity = (Activity) getContext(); activity.startActivityForResult(chooserIntent, BaseWebActivity.FILE_CHOOSER_RESULTCODE_FOR_ANDROID_5); }
Example 11
Source File: WebViewActivity.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); WebViewActivity.this.startActivityForResult(chooserIntent, 201); }
Example 12
Source File: X5WebChromeClient.java From YCWebView with Apache License 2.0 | 5 votes |
/** * 打开文件夹,Android5.0以上 * @param uploadMsg msg */ private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { if (context!=null && context instanceof Activity){ Activity activity = (Activity) context; mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); activity.startActivityForResult(chooserIntent, FILE_CHOOSER_RESULT_CODE_5); } }
Example 13
Source File: MyWebChromeClient.java From NetEasyNews with GNU General Public License v3.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); mActivity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5); }
Example 14
Source File: MyWebChromeClient.java From MaoWanAndoidClient with Apache License 2.0 | 5 votes |
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) { mUploadMessageForAndroid5 = uploadMsg; Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择"); mIWebPageView.startFileChooserForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5); }
Example 15
Source File: BrowserActivity.java From JumpGo with Mozilla Public License 2.0 | 4 votes |
@Override public void showFileChooser(ValueCallback<Uri[]> filePathCallback) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = Utils.createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Log.e(TAG, "Unable to create Image File", ex); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("*/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[]{takePictureIntent}; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, 1); }
Example 16
Source File: BrowserActivity.java From Xndroid with GNU General Public License v3.0 | 4 votes |
@Override public void showFileChooser(ValueCallback<Uri[]> filePathCallback) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(this.getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = Utils.createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Log.e(TAG, "Unable to create Image File", ex); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("*/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[]{takePictureIntent}; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, 1); }
Example 17
Source File: PrivateActivity.java From SimplicityBrowser with MIT License | 4 votes |
public boolean onShowFileChooser( WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { requestStoragePermission(); if (!hasStoragePermission()) return false; if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // create the file where the photo should go File photoFile; photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); // continue only if the file was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("*/*"); contentSelectionIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[]{"image/*", "video/*", "*/*"}); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[]{takePictureIntent}; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Choose file"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); return true; }
Example 18
Source File: MainActivity.java From SimplicityBrowser with MIT License | 4 votes |
public boolean onShowFileChooser( WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { requestStoragePermission(); if (!hasStoragePermission()) return false; if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // create the file where the photo should go File photoFile; photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); // continue only if the file was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("*/*"); contentSelectionIntent.putExtra(Intent.EXTRA_MIME_TYPES, new String[]{"image/*", "video/*", "*/*"}); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[]{takePictureIntent}; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Choose file"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); return true; }
Example 19
Source File: BrowserActivity.java From browser with GNU General Public License v2.0 | 4 votes |
@Override public void showFileChooser(ValueCallback<Uri[]> filePathCallback) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = Utils.createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Log.e(Constants.TAG, "Unable to create Image File", ex); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); mActivity.startActivityForResult(chooserIntent, 1); }
Example 20
Source File: SelectFileDialog.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Creates and starts an intent based on the passed fileTypes and capture value. * @param fileTypes MIME types requested (i.e. "image/*") * @param capture The capture value as described in http://www.w3.org/TR/html-media-capture/ * @param window The WindowAndroid that can show intents */ @CalledByNative private void selectFile(String[] fileTypes, boolean capture, WindowAndroid window) { mFileTypes = new ArrayList<String>(Arrays.asList(fileTypes)); mCapture = capture; Intent chooser = new Intent(Intent.ACTION_CHOOSER); Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mCameraOutputUri = Uri.fromFile(getFileForImageCapture()); camera.putExtra(MediaStore.EXTRA_OUTPUT, mCameraOutputUri); Intent camcorder = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); Intent soundRecorder = new Intent( MediaStore.Audio.Media.RECORD_SOUND_ACTION); // Quick check - if the |capture| parameter is set and |fileTypes| has the appropriate MIME // type, we should just launch the appropriate intent. Otherwise build up a chooser based on // the accept type and then display that to the user. if (captureCamera()) { if (window.showIntent(camera, this, R.string.low_memory_error)) return; } else if (captureCamcorder()) { if (window.showIntent(camcorder, this, R.string.low_memory_error)) return; } else if (captureMicrophone()) { if (window.showIntent(soundRecorder, this, R.string.low_memory_error)) return; } Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT); getContentIntent.addCategory(Intent.CATEGORY_OPENABLE); ArrayList<Intent> extraIntents = new ArrayList<Intent>(); if (!noSpecificType()) { // Create a chooser based on the accept type that was specified in the webpage. Note // that if the web page specified multiple accept types, we will have built a generic // chooser above. if (shouldShowImageTypes()) { extraIntents.add(camera); getContentIntent.setType(ALL_IMAGE_TYPES); } else if (shouldShowVideoTypes()) { extraIntents.add(camcorder); getContentIntent.setType(ALL_VIDEO_TYPES); } else if (shouldShowAudioTypes()) { extraIntents.add(soundRecorder); getContentIntent.setType(ALL_AUDIO_TYPES); } } if (extraIntents.isEmpty()) { // We couldn't resolve an accept type, so fallback to a generic chooser. getContentIntent.setType(ANY_TYPES); extraIntents.add(camera); extraIntents.add(camcorder); extraIntents.add(soundRecorder); } chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents.toArray(new Intent[] { })); chooser.putExtra(Intent.EXTRA_INTENT, getContentIntent); if (!window.showIntent(chooser, this, R.string.low_memory_error)) { onFileNotSelected(); } }