本文整理汇总了Java中android.content.Intent.setClipData方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.setClipData方法的具体用法?Java Intent.setClipData怎么用?Java Intent.setClipData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.setClipData方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPhotosResult
import android.content.Intent; //导入方法依赖的package包/类
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();
}
}
示例2: onFinished
import android.content.Intent; //导入方法依赖的package包/类
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();
}
示例3: prepare
import android.content.Intent; //导入方法依赖的package包/类
/**
* Prepare the intent.
* @param context
* the context
* @return
* the intent.
*/
protected Intent prepare(Context context) {
Intent intent = replacedIntent != null ? replacedIntent : getIntent();
intent = intent == null ? new Intent() : intent;
if(callback != null) {
callback.prepare(intent);
}
if(flags != 0) {
intent.addFlags(flags);
}
if(!TextUtils.isEmpty(mimeType)) {
intent.setType(mimeType);
}
if(clipData != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
intent.setClipData(clipData);
}
return intent;
}
示例4: onFinished
import android.content.Intent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
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]);
}
}
if (mState.action == DocumentsActivity.State.ACTION_GET_CONTENT) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
} else if (mState.action == ACTION_OPEN_TREE) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION
| Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
} else {
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();
}
示例5: getShareIntent
import android.content.Intent; //导入方法依赖的package包/类
@VisibleForTesting
public static Intent getShareIntent(Activity activity, String title, String text, String url,
Uri offlineUri, Uri screenshotUri) {
if (!TextUtils.isEmpty(url)) {
url = DomDistillerUrlUtils.getOriginalUrlFromDistillerUrl(url);
if (!TextUtils.isEmpty(text)) {
// Concatenate text and URL with a space.
text = text + " " + url;
} else {
text = url;
}
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag());
intent.putExtra(Intent.EXTRA_SUBJECT, title);
intent.putExtra(Intent.EXTRA_TEXT, text);
intent.putExtra(EXTRA_TASK_ID, activity.getTaskId());
if (screenshotUri != null) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
if (screenshotUri != null) {
// 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);
}
if (offlineUri == null) {
intent.setType("text/plain");
} else {
intent.setType("multipart/related");
intent.putExtra(Intent.EXTRA_STREAM, offlineUri);
}
return intent;
}
示例6: addResultsToIntent
import android.content.Intent; //导入方法依赖的package包/类
static void addResultsToIntent(RemoteInput[] remoteInputs, Intent intent, Bundle results) {
Bundle resultsBundle = new Bundle();
for (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("android.remoteinput.resultsData", resultsBundle);
intent.setClipData(ClipData.newIntent("android.remoteinput.results", clipIntent));
}