本文整理了Java中android.content.Intent.getClipData()
方法的一些代码示例,展示了Intent.getClipData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.getClipData()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:getClipData
暂无
代码示例来源:origin: commonsguy/cw-omnibus
@Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data) {
switch(requestCode) {
case REQUEST_OPEN:
if (resultCode==Activity.RESULT_OK) {
if (data.getData()==null) {
ClipData clip=data.getClipData();
for (int i=0;i<clip.getItemCount();i++) {
openEditor(clip.getItemAt(i).getUri());
}
}
else {
openEditor(data.getData());
}
}
break;
case REQUEST_CREATE:
if (resultCode==Activity.RESULT_OK) {
openEditor(data.getData());
}
break;
}
}
代码示例来源:origin: k9mail/k-9
private void addAttachmentsFromResultIntent(Intent data) {
// TODO draftNeedsSaving = true
ClipData clipData = data.getClipData();
if (clipData != null) {
for (int i = 0, end = clipData.getItemCount(); i < end; i++) {
Uri uri = clipData.getItemAt(i).getUri();
if (uri != null) {
addAttachment(uri);
}
}
return;
}
Uri uri = data.getData();
if (uri != null) {
addAttachment(uri);
}
}
代码示例来源:origin: Justson/AgentWeb
private Uri[] processData(Intent data) {
Uri[] datas = null;
if (data == null) {
return datas;
}
String target = data.getDataString();
if (!TextUtils.isEmpty(target)) {
return datas = new Uri[]{Uri.parse(target)};
}
ClipData mClipData = data.getClipData();
if (mClipData != null && mClipData.getItemCount() > 0) {
datas = new Uri[mClipData.getItemCount()];
for (int i = 0; i < mClipData.getItemCount(); i++) {
ClipData.Item mItem = mClipData.getItemAt(i);
datas[i] = mItem.getUri();
}
}
return datas;
}
代码示例来源:origin: elvishew/xLog
ClipData mClipData = intent.getClipData();
if (mClipData != null) {
if (!first) {
代码示例来源:origin: jkwiecien/EasyImage
private static boolean isPhoto(Intent data) {
return data == null || (data.getData() == null && data.getClipData() == null);
}
代码示例来源:origin: stackoverflow.com
if (data.getClipData() != null) {
ClipData mClipData = data.getClipData();
ArrayList<Uri> mArrayUri = new ArrayList<Uri>();
for (int i = 0; i < mClipData.getItemCount(); i++) {
代码示例来源:origin: delight-im/Android-AdvancedWebView
if (intent.getClipData() != null) {
final int numSelectedFiles = intent.getClipData().getItemCount();
dataUris[i] = intent.getClipData().getItemAt(i).getUri();
代码示例来源:origin: jkwiecien/EasyImage
private static void onPictureReturnedFromGallery(Intent data, Activity activity, @NonNull Callbacks callbacks) {
try {
ClipData clipData = data.getClipData();
List<File> files = new ArrayList<>();
if (clipData == null) {
Uri uri = data.getData();
File file = EasyImageFiles.pickedExistingPicture(activity, uri);
files.add(file);
} else {
for (int i = 0; i < clipData.getItemCount(); i++) {
Uri uri = clipData.getItemAt(i).getUri();
File file = EasyImageFiles.pickedExistingPicture(activity, uri);
files.add(file);
}
}
if (configuration(activity).shouldCopyPickedImagesToPublicGalleryAppFolder()) {
EasyImageFiles.copyFilesInSeparateThread(activity, files);
}
callbacks.onImagesPicked(files, ImageSource.GALLERY, restoreType(activity));
} catch (Exception e) {
e.printStackTrace();
callbacks.onImagePickerError(e, ImageSource.GALLERY, restoreType(activity));
}
}
代码示例来源:origin: stackoverflow.com
Intent i = myActivity.getIntent();
String url = i.getClipData();
String title = i.getStringExtra(Intent.EXTRA_TITLE); //Title of content
String text = i.getStringExtra(Intent.EXTRA_TEXT); //Content
String subject = i.getStringExtra(Intent.EXTRA_SUBJECT); //Subject in case "mail"
代码示例来源:origin: googlecodelabs/android-workmanager
private void handleImageRequestResult(Intent data) {
Uri imageUri = null;
if (data.getClipData() != null) {
imageUri = data.getClipData().getItemAt(0).getUri();
} else if (data.getData() != null) {
imageUri = data.getData();
}
if (imageUri == null) {
Log.e(TAG, "Invalid input image Uri.");
return;
}
Intent filterIntent = new Intent(this, BlurActivity.class);
filterIntent.putExtra(Constants.KEY_IMAGE_URI, imageUri.toString());
startActivity(filterIntent);
}
}
代码示例来源:origin: marchinram/RxGallery
private ArrayList<Uri> handleGallery(Intent data) {
ArrayList<Uri> uris = new ArrayList<>();
if (data.getData() != null) { // Single select
uris.add(data.getData());
} else { // Multi select
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
ClipData clipData = data.getClipData();
if (clipData != null) {
for (int i = 0; i < clipData.getItemCount(); i++) {
uris.add(clipData.getItemAt(i).getUri());
}
}
}
}
return uris;
}
代码示例来源:origin: stackoverflow.com
private Uri detectFileToUploadUri(Intent data) {
Uri result = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ClipData clip = data.getClipData();
if (clip != null) {
for (int i = 0; i < clip.getItemCount(); i++) {
Uri uri = clip.getItemAt(i).getUri();
if (uri != null) {
result = uri;
break;
}
}
}
}
if (result == null && data.getData() != null) {
result = data.getData();
}
return result;
}
代码示例来源:origin: alhazmy13/MediaPicker
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
static List<String> processMultiVideos(Context context, Intent data) {
List<String> listOfImgs = new ArrayList<>();
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) && (null == data.getData())) {
ClipData clipdata = data.getClipData();
for (int i = 0; i < clipdata.getItemCount(); i++) {
Uri selectedImage = clipdata.getItemAt(i).getUri();
String selectedImagePath = FileProcessing.getPath(context, selectedImage);
listOfImgs.add(selectedImagePath);
}
}
return listOfImgs;
}
}
代码示例来源:origin: stackoverflow.com
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == REQUEST_CODE)
{
if(data != null)
{
ClipData clipData = data.getClipData();
for(int i = 0; i < clipData.getItemCount(); i++)
{
ClipData.Item path = clipData.getItemAt(i);
Log.i("Path:",path.toString());
}
}
}
}
代码示例来源:origin: miguelbcr/RxPaparazzo
private List<Uri> getUris(Intent intent) {
List<Uri> uris = new ArrayList<>();
ClipData clipData = intent.getClipData();
if (clipData != null) {
for (int i = 0; i < clipData.getItemCount(); i++) {
ClipData.Item item = clipData.getItemAt(i);
Uri uri = item.getUri();
PermissionUtil.grantReadPermissionToUri(targetUi, uri);
uris.add(uri);
}
}
return uris;
}
代码示例来源:origin: alhazmy13/MediaPicker
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static List<String> processMultiImage(Context context, Intent data) {
List<String> listOfImgs = new ArrayList<>();
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) && (null == data.getData()))
{
ClipData clipdata = data.getClipData();
for (int i = 0; i< (clipdata != null ? clipdata.getItemCount() : 0); i++)
{
Uri selectedImage = clipdata.getItemAt(i).getUri();
String selectedImagePath = FileProcessing.getPath(context, selectedImage);
listOfImgs.add(selectedImagePath);
}
}
return listOfImgs;
}
代码示例来源:origin: kingargyle/adt-leanback-support
static Bundle getResultsFromIntent(Intent intent) {
ClipData clipData = intent.getClipData();
if (clipData == null) {
return null;
}
ClipDescription clipDescription = clipData.getDescription();
if (!clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
return null;
}
if (clipDescription.getLabel().equals(RESULTS_CLIP_LABEL)) {
return clipData.getItemAt(0).getIntent().getExtras().getParcelable(EXTRA_RESULTS_DATA);
}
return null;
}
代码示例来源:origin: cloudinary/cloudinary_android
private void uploadImageFromIntentUri(Intent data) {
final int takeFlags = data.getFlags()
& (Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
Uri uri = data.getData();
if (uri != null) {
handleUri(uri, takeFlags);
} else if (data.getClipData() != null) {
ClipData clip = data.getClipData();
for (int i = 0; i < clip.getItemCount(); i++) {
handleUri(clip.getItemAt(i).getUri(), takeFlags);
}
}
}
代码示例来源:origin: konradrenner/kolabnotes-android
private void loadImageFromIntent(Intent resultData) {
Uri uri = resultData.getData();
if(uri != null){
loadImageFromUri(uri);
}else{
//in case of getting image via share intent from other app
final ClipData clipData = resultData.getClipData();
for(int i=0;i<clipData.getItemCount();i++){
loadImageFromUri(clipData.getItemAt(i).getUri());
}
}
}
代码示例来源:origin: doo/scanbot-sdk-example-android
private void processGalleryResult(Intent data) {
ClipData clipData = data.getClipData();
Uri imageUri = data.getData();
if (clipData != null && clipData.getItemCount() > 0) {
List<Uri> imageUris = getImageUris(clipData);
new WriteMultiPageTIFFImageTask(imageUris).execute();
} else if (imageUri != null) {
new WriteTIFFImageTask(imageUri).execute();
}
}
内容来源于网络,如有侵权,请联系作者删除!