本文整理汇总了Java中org.chromium.ui.WindowAndroid.showIntent方法的典型用法代码示例。如果您正苦于以下问题:Java WindowAndroid.showIntent方法的具体用法?Java WindowAndroid.showIntent怎么用?Java WindowAndroid.showIntent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.chromium.ui.WindowAndroid
的用法示例。
在下文中一共展示了WindowAndroid.showIntent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectFile
import org.chromium.ui.WindowAndroid; //导入方法依赖的package包/类
/**
* 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();
}
}