本文整理汇总了Java中android.content.Intent.ACTION_GET_CONTENT属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_GET_CONTENT属性的具体用法?Java Intent.ACTION_GET_CONTENT怎么用?Java Intent.ACTION_GET_CONTENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.ACTION_GET_CONTENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: chooseFile
private void chooseFile() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
getActivity().startActivityForResult(
Intent.createChooser(intent, "Select a File to Upload"),
FILE_SELECT_CODE);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
Toast.makeText(getActivity(), "Please install a File Manager.",
Toast.LENGTH_SHORT).show();
}
// Intent intent = new Intent(getActivity(), NormalFilePickActivity.class);
// intent.putExtra(Constant.MAX_NUMBER, 1);
// intent.putExtra(NormalFilePickActivity.SUFFIX, new String[] {"xlsx", "xls", "doc", "docx", "ppt", "pptx", "pdf"});
// startActivityForResult(intent, Constant.REQUEST_CODE_PICK_FILE);
}
示例2: pickCsvFile
private void pickCsvFile() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
String[] mimetypes = {"text/comma-separated-values", "text/csv"};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
intent.putExtra(EXTRA_MIME_TYPES, mimetypes);
}
startActivityForResult(Intent.createChooser(intent, getString(R.string.pick_file)), REQUEST_CODE_PICK_CSV);
}
示例3: onRequestPermissionsResult
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
{
if (requestCode == MY_PERMISSIONS_REQUEST_CALL_PHONE2)
{
if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
{
Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent,PICK_PHOTO);
} else
{
// Permission Denied
Toast.makeText(ObjectCardActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show();
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
示例4: onCreate
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
switch (getIntent().getAction()) {
case "com.android.camera.action.REVIEW":
case Intent.ACTION_VIEW:
view(getIntent());
this.finish();
break;
case Intent.ACTION_PICK:
pick(getIntent());
break;
case Intent.ACTION_GET_CONTENT:
pick(getIntent());
break;
case Intent.ACTION_EDIT:
edit(getIntent());
break;
default:
break;
}
}
示例5: PhotoAppsAdapter
public PhotoAppsAdapter(Context context, File captureFile, int captureCode, int importCode) {
page = 0;
this.context = context;
this.captureFile = captureFile;
this.captureCode = captureCode;
this.importCode = importCode;
packageManager = context.getPackageManager();
Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", captureFile);
captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
//captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(captureFile));
importIntent = new Intent(Intent.ACTION_GET_CONTENT);
importIntent.setType("image/jpg");
importList = packageManager.queryIntentActivities(importIntent, PackageManager.MATCH_DEFAULT_ONLY);
}
示例6: onMenuItemClick
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.action_local) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("video/*.mp4");
startActivityForResult(intent, PICK_FILE_REQUEST_CODE);
} else if (item.getItemId() == R.id.action_toggle) {
if (previewTimeBarLayout.isShowingPreview()) {
previewTimeBarLayout.hidePreview();
exoPlayerManager.stopPreview();
} else {
previewTimeBarLayout.showPreview();
exoPlayerManager.loadPreview(previewTimeBar.getProgress(),
previewTimeBar.getDuration());
}
} else {
startActivity(new Intent(this, LocalActivity.class));
}
return true;
}
示例7: fromGallery
/**
* 启动手机相册
*/
private void fromGallery() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory(), IMAGE_NAME)));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
startActivityForResult(intent, GALLERY_KITKAT_REQUEST);
} else {
startActivityForResult(intent, GALLERY_REQUEST);
}
// Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
// startActivityForResult(intent, 103);103
}
示例8: onClick
@Override
public void onClick(View v) {
final int id = v.getId();
if(id==R.id.capture_scan_photo){
// 打开手机中的相册
Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); // "android.intent.action.GET_CONTENT"
innerIntent.setType("image/*");
Intent wrapperIntent = Intent.createChooser(innerIntent,
"选择二维码图片");
this.startActivityForResult(wrapperIntent, REQUEST_CODE);
}else if(id==R.id.capture_flashlight){
if (isFlashlightOpen) {
cameraManager.setTorch(false); // 关闭闪光灯
isFlashlightOpen = false;
}
else {
cameraManager.setTorch(true); // 打开闪光灯
isFlashlightOpen = true;
}
}
}
示例9: chooseImg
private void chooseImg() {
try {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("image/*");
intent.putExtra("crop", true);
intent.putExtra("return-data", true);
startActivityForResult(intent, LOAD_PIC);
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: openFileChooserImplForAndroid5
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);
}
示例11: createGetContentIntent
/**
* Get the Intent for selecting content to be used in an Intent Chooser.
*
* @return The intent for opening a file with Intent.createChooser()
* @author paulburke
*/
public static Intent createGetContentIntent() {
// Implicitly allow the user to select a particular kind of data
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
// The MIME data type filter
intent.setType("*/*");
// Only return URIs that can be opened with ContentResolver
intent.addCategory(Intent.CATEGORY_OPENABLE);
return intent;
}
示例12: openAlbumC
public void openAlbumC(View v){
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_CALL_PHONE2);
}
else {
Intent intent=new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent,PICK_PHOTO);}
}
示例13: addMedia
public void addMedia()
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType(WILD_WILD);
startActivityForResult(Intent.createChooser(intent, null), ADD_MEDIA);
}
示例14: selectFile
public static void selectFile(Activity mActivity, int requestCode) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("file/*");
mActivity.startActivityForResult(intent, requestCode);
}
示例15: onShowFileChooser
public boolean onShowFileChooser(
WebView webView, ValueCallback<Uri[]> filePathCallback,
FileChooserParams fileChooserParams) {
if (mFilePathCallback != null) {
mFilePathCallback.onReceiveValue(null);
}
mFilePathCallback = filePathCallback;
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = helper_browser.createImageFile();
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
} catch (IOException e) {
// Error occurred while creating the File
Log.e(TAG, "Unable to create Image File", e);
}
// 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, getString(R.string.app_share_file));
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivityForResult(chooserIntent, REQUEST_CODE_LOLLIPOP);
return true;
}