本文整理了Java中android.content.Intent.setClipData()
方法的一些代码示例,展示了Intent.setClipData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.setClipData()
方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:setClipData
暂无
代码示例来源:origin: commonsguy/cw-omnibus
ClipData.newUri(getContentResolver(), "A photo", outputUri);
i.setClipData(clip);
i.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
代码示例来源:origin: stackoverflow.com
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setClipData(ClipData.newRawUri(null, contentUri));
intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri);
代码示例来源:origin: stackoverflow.com
void onTaskFinished(Uri... uris) {
Log.d(TAG, "onFinished() " + Arrays.toString(uris));
final Intent intent = new Intent();
if (uris.length == 1) {
intent.setData(uris[0]);
} else if (uris.length > 1) {
final ClipData clipData = new ClipData(
null, mState.acceptMimes, new ClipData.Item(uris[0]));
for (int i = 1; i < uris.length; i++) {
clipData.addItem(new ClipData.Item(uris[i]));
}
intent.setClipData(clipData);
}
代码示例来源:origin: stackoverflow.com
private void showCamera() {
try {
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "DCIM");
if (!file.exists()) {
file.mkdirs();
}
File localFile2 = new File(file + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg");
imageUri = Uri.fromFile(localFile2);
Intent cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
cameraIntent.setClipData(ClipData.newRawUri(null, Uri.fromFile(localFile2)));
}
startActivityForResult(cameraIntent, REQUEST_CAMERA);
} catch (Exception localException) {
Toast.makeText(ActivityAddMemory.this, "Exception:" + localException, Toast.LENGTH_SHORT).show();
}
}
代码示例来源:origin: stackoverflow.com
private void selectFromCamera() {
try {
File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "DCIM");
if (!file.exists()) {
file.mkdirs();
}
File localFile = new File(file + File.separator + "IMG_" + String.valueOf(System.currentTimeMillis()) + ".jpg");
imageUri = Uri.fromFile(localFile);
Intent cameraIntent = new Intent("android.media.action.IMAGE_CAPTURE");
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
cameraIntent.setClipData(ClipData.newRawUri(null, Uri.fromFile(localFile)));
}
startActivityForResult(cameraIntent, REQUEST_CAMERA);
} catch (Exception localException) {
Toast.makeText(ActivityAddMemory.this, "Exception:" + localException, Toast.LENGTH_SHORT).show();
}
}
private void selectFromGallery() {
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
}
代码示例来源:origin: derry/delion
@VisibleForTesting
public static Intent getShareIntent(String title, String url, Uri screenshotUri) {
url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag());
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, title);
intent.putExtra(Intent.EXTRA_TEXT, url);
if (screenshotUri != null) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// To give read access to an Intent target, we need to put |screenshotUri| in clipData
// because adding Intent.FLAG_GRANT_READ_URI_PERMISSION doesn't work for
// EXTRA_SHARE_SCREENSHOT_AS_STREAM.
intent.setClipData(ClipData.newRawUri("", screenshotUri));
intent.putExtra(EXTRA_SHARE_SCREENSHOT_AS_STREAM, screenshotUri);
}
return intent;
}
代码示例来源:origin: kingargyle/adt-leanback-support
static void addResultsToIntent(RemoteInputCompatBase.RemoteInput[] remoteInputs, Intent intent,
Bundle results) {
Bundle resultsBundle = new Bundle();
for (RemoteInputCompatBase.RemoteInput remoteInput : remoteInputs) {
Object result = results.get(remoteInput.getResultKey());
if (result instanceof CharSequence) {
resultsBundle.putCharSequence(remoteInput.getResultKey(), (CharSequence) result);
}
}
Intent clipIntent = new Intent();
clipIntent.putExtra(EXTRA_RESULTS_DATA, resultsBundle);
intent.setClipData(ClipData.newIntent(RESULTS_CLIP_LABEL, clipIntent));
}
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
ClipData.newUri(activity.getContentResolver(), "a Video", videoFileUri);
videoIntent.setClipData(clip);
videoIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
videoIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: AppLozic/Applozic-Android-SDK
ClipData.newUri(activity.getContentResolver(), "a Photo", capturedImageUri);
cameraIntent.setClipData(clip);
cameraIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
cameraIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: THEONE10211024/ApiDemos
@Override public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri.Builder b = new Uri.Builder();
b.scheme("content");
b.authority("com.example.android.apis.content.FileProvider");
TypedValue tv = new TypedValue();
getResources().getValue(R.drawable.jellies, tv, true);
b.appendEncodedPath(Integer.toString(tv.assetCookie));
b.appendEncodedPath(tv.string.toString());
Uri uri = b.build();
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setClipData(ClipData.newUri(getContentResolver(), "image", uri));
startActivity(Intent.createChooser(intent, "Select share target"));
}
});
代码示例来源:origin: qiubiteme/android_api_demos
@Override public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri.Builder b = new Uri.Builder();
b.scheme("content");
b.authority("com.example.android.apis.content.FileProvider");
TypedValue tv = new TypedValue();
getResources().getValue(R.drawable.jellies, tv, true);
b.appendEncodedPath(Integer.toString(tv.assetCookie));
b.appendEncodedPath(tv.string.toString());
Uri uri = b.build();
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setClipData(ClipData.newUri(getContentResolver(), "image", uri));
startActivity(Intent.createChooser(intent, "Select share target"));
}
});
代码示例来源:origin: osmandapp/osmand-api-demo
/**
* Creates intent and executes request.
*
* @param intentBuilder - contains intent parameters.
*/
private void sendRequest(OsmAndIntentBuilder intentBuilder) {
try {
Uri uri = intentBuilder.getUri();
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.addFlags(intentBuilder.getFlags());
Map<String, String> extraData = intentBuilder.getExtraData();
if (extraData != null) {
for (String key : extraData.keySet()) {
intent.putExtra(key, extraData.get(key));
}
}
if (intentBuilder.getGpxUri() != null) {
ClipData clipData = ClipData.newRawUri("Gpx", intentBuilder.getGpxUri());
intent.setClipData(clipData);
}
if (isIntentSafe(intent)) {
mActivity.startActivityForResult(intent, mRequestCode);
} else {
mOsmandMissingListener.osmandMissing();
}
} catch (Exception e) {
Toast.makeText(mActivity, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
ClipData.newUri(getContentResolver(), "a Video", videoFileUri);
videoIntent.setClipData(clip);
videoIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
videoIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: AppLozic/Applozic-Android-SDK
ClipData.newUri(getContentResolver(), "a Photo", capturedImageUri);
cameraIntent.setClipData(clip);
cameraIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
cameraIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: spacecowboy/NoNonsense-FilePicker
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onFilesPicked(@NonNull final List<Uri> files) {
Intent i = new Intent();
i.putExtra(EXTRA_ALLOW_MULTIPLE, true);
// Set as String Extras for all versions
ArrayList<String> paths = new ArrayList<>();
for (Uri file : files) {
paths.add(file.toString());
}
i.putStringArrayListExtra(EXTRA_PATHS, paths);
// Set as Clip Data for Jelly bean and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
ClipData clip = null;
for (Uri file : files) {
if (clip == null) {
clip = new ClipData("Paths", new String[]{},
new ClipData.Item(file));
} else {
clip.addItem(new ClipData.Item(file));
}
}
i.setClipData(clip);
}
setResult(Activity.RESULT_OK, i);
finish();
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
ClipData.newUri(getContentResolver(), "a Photo", uri);
shareIntent.setClipData(clip);
shareIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
代码示例来源:origin: gigabytedevelopers/FireFiles
intent.setClipData(clipData);
代码示例来源:origin: gigabytedevelopers/FireFiles
private void onFinished(Uri... uris) {
Log.d(TAG, "onFinished() " + Arrays.toString(uris));
final Intent intent = new Intent();
if (uris.length == 1) {
intent.setData(uris[0]);
} else if (uris.length > 1) {
final ClipData clipData = new ClipData(
null, mState.acceptMimes, new ClipData.Item(uris[0]));
for (int i = 1; i < uris.length; i++) {
clipData.addItem(new ClipData.Item(uris[i]));
}
if(Utils.hasJellyBean()){
intent.setClipData(clipData);
}
else{
intent.setData(uris[0]);
}
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
setResult(Activity.RESULT_OK, intent);
finish();
}
private class CreateFinishTask extends AsyncTask<Void, Void, Uri> {
代码示例来源:origin: kollerlukas/Camera-Roll-Android-App
public void setPhotosResult() {
final AlbumItem[] selected_items = SelectorModeManager
.createAlbumItemArray(recyclerViewAdapter.cancelSelectorMode(this));
Intent intent = new Intent("us.koller.RESULT_ACTION");
if (allowMultiple) {
ClipData clipData = createClipData(selected_items);
intent.setClipData(clipData);
} else {
intent.setData(selected_items[0].getUri(this));
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
setResult(RESULT_OK, intent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAfterTransition();
} else {
finish();
}
}
代码示例来源:origin: AppLozic/Applozic-Android-SDK
ClipData.newUri(getActivity().getContentResolver(), "a Photo", capturedImageUri);
cameraIntent.setClipData(clip);
cameraIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
cameraIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
内容来源于网络,如有侵权,请联系作者删除!