本文整理汇总了Java中android.content.Intent.getClipData方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getClipData方法的具体用法?Java Intent.getClipData怎么用?Java Intent.getClipData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getClipData方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GetAllPath
import android.content.Intent; //导入方法依赖的package包/类
public static ArrayList<String> GetAllPath(final Context context, Intent data) {
ArrayList<String> Paths = new ArrayList<>();
if (data.getClipData() != null) {
int count = data.getClipData().getItemCount();
for (int i = 0; i < count; i++) {
Paths.add(
getRealPath(context, data.getClipData().getItemAt(i).getUri())
);
}
}
if (data.getData() != null) {
Paths.add(
getRealPath(context, data.getData())
);
}
return Paths;
}
示例2: processData
import android.content.Intent; //导入方法依赖的package包/类
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;
}
示例3: importVideo
import android.content.Intent; //导入方法依赖的package包/类
static private void importVideo(Intent data) {
Uri uri = data.getData();
Log.d(TAG,"importVideo: uri:" + uri);
Log.d(TAG,"importVideo: type: " + data.getType());
if (data.getClipData() != null) {
importVideoFromClipData(data);
} else if (uri != null ) {
if (uri.getScheme().equals("file")) {
importVideoFromFileUri(uri);
} else {
importVideoFromContentUri(uri);
}
}
}
示例4: importVideoFromClipData
import android.content.Intent; //导入方法依赖的package包/类
private static void importVideoFromClipData(Intent data) {
ClipData clipData = data.getClipData();
Log.d(TAG,"Video importFromClipData");
if (clipData.getItemCount() == 0)
return;
ArrayList<Uri> uris = new ArrayList(clipData.getItemCount());
for (int i = 0 ; i < clipData.getItemCount() ; i++ ){
Uri uri = clipData.getItemAt(i).getUri();
uris.add(resolveUri(uri));
}
importVideoFromFileUri(uris);
}
示例5: importImage
import android.content.Intent; //导入方法依赖的package包/类
static private void importImage(Intent data) {
Uri uri = data.getData();
Log.d(TAG,"importImage: uri:" + uri);
Log.d(TAG,"importImage: type: " + data.getType());
if (data.getClipData() != null) {
importImageFromClipData(data);
} else if (uri != null ) {
if (uri.getScheme().equals("file")) {
importImageFromFileUri(uri);
} else {
importImageFromContentUri(uri);
}
}
}
示例6: importImageFromClipData
import android.content.Intent; //导入方法依赖的package包/类
private static void importImageFromClipData(Intent data) {
ClipData clipData = data.getClipData();
Log.d(TAG,"importFromClipData");
if (clipData.getItemCount() == 0)
return;
ArrayList<Uri> uris = new ArrayList(clipData.getItemCount());
for (int i = 0 ; i < clipData.getItemCount() ; i++ ){
Uri uri = clipData.getItemAt(i).getUri();
uris.add(resolveUri(uri));
}
importImageFromFileUri(uris);
}
示例7: onActivityResultAboveL
import android.content.Intent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent) {
if (requestCode != FILECHOOSER_RESULTCODE || mUploadCallbackAboveL == null)
return;
Uri[] results = null;
if (resultCode == Activity.RESULT_OK) {
if (intent != null) {
String dataString = intent.getDataString();
ClipData clipData = intent.getClipData();
if (clipData != null) {
results = new Uri[clipData.getItemCount()];
for (int i = 0; i < clipData.getItemCount(); i++) {
ClipData.Item item = clipData.getItemAt(i);
results[i] = item.getUri();
}
}
if (dataString != null)
results = new Uri[]{Uri.parse(dataString)};
}
}
mUploadCallbackAboveL.onReceiveValue(results);
mUploadCallbackAboveL = null;
}
示例8: cleanUpOnBackFromFileChooser
import android.content.Intent; //导入方法依赖的package包/类
/**
* カメラやギャラリーから戻ってきたときの処理 (onActivityResultで呼ぶ)
*/
public void cleanUpOnBackFromFileChooser(Context context, int resultCode, Intent intent) {
if (filePathCallback == null) {
return;
}
if (resultCode != Activity.RESULT_OK) {
// 画像選択をキャンセルした場合
deletePhotoFile(context);
filePathCallback.onReceiveValue(null);
return;
}
if (intent != null) {
// ギャラリーで選択した場合
// 画像を1枚選択した場合、intent.getData()に選択した画像のURIが入ってくる
Uri onlyOneSelectedImageUri = intent.getData();
// 画像を複数枚選択した場合(複数枚選択モード時)、intent.getClipData()に複数枚選択した画像のURIが入ってくる
ClipData multipleSelectedImageUriData = intent.getClipData();
// 複数枚選択した場合、intent.getData()に画像URIが入ってくるので、先にintent.getClipData()を判定している
if (multipleSelectedImageUriData != null) {
final int selectedFilesCount = multipleSelectedImageUriData.getItemCount();
Uri[] results = new Uri[selectedFilesCount];
for (int i = 0; i < selectedFilesCount; i++) {
results[i] = multipleSelectedImageUriData.getItemAt(i).getUri();
}
filePathCallback.onReceiveValue(results);
} else if (onlyOneSelectedImageUri != null) {
filePathCallback.onReceiveValue(new Uri[]{onlyOneSelectedImageUri});
} else {
receivePhotoFileForCamera(context);
}
} else {
// https://stackoverflow.com/questions/12564112/android-camera-onactivityresult-intent-is-null-if-it-had-extras
receivePhotoFileForCamera(context);
}
filePathCallback = null;
}
示例9: onActivityResultAboveL
import android.content.Intent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent)
{
if (requestCode != FILE_CHOOSER_RESULT_CODE || uploadMessageAboveL == null)
return;
Uri[] results = null;
if (resultCode == Activity.RESULT_OK)
{
if (intent != null)
{
String dataString = intent.getDataString();
ClipData clipData = intent.getClipData();
if (clipData != null)
{
results = new Uri[clipData.getItemCount()];
for (int i = 0; i < clipData.getItemCount(); i++)
{
ClipData.Item item = clipData.getItemAt(i);
results[i] = item.getUri();
}
}
if (dataString != null)
results = new Uri[]{Uri.parse(dataString)};
}
}
uploadMessageAboveL.onReceiveValue(results);
uploadMessageAboveL = null;
}
示例10: getShareUri
import android.content.Intent; //导入方法依赖的package包/类
static Uri getShareUri(Intent intent) {
Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
if (uri == null) {
ClipData clip = intent.getClipData();
if (clip != null && clip.getItemCount() > 0) {
uri = clip.getItemAt(0).getUri();
}
}
return uri;
}
示例11: getResultsFromIntent
import android.content.Intent; //导入方法依赖的package包/类
static Bundle getResultsFromIntent(Intent intent) {
ClipData clipData = intent.getClipData();
if (clipData == null) {
return null;
}
ClipDescription clipDescription = clipData.getDescription();
if (clipDescription.hasMimeType("text/vnd.android.intent") && clipDescription.getLabel().equals("android.remoteinput.results")) {
return (Bundle) clipData.getItemAt(0).getIntent().getExtras().getParcelable("android.remoteinput.resultsData");
}
return null;
}
示例12: handleGallery
import android.content.Intent; //导入方法依赖的package包/类
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();
for (int i = 0; i < clipData.getItemCount(); i++) {
uris.add(clipData.getItemAt(i).getUri());
}
}
}
return uris;
}
示例13: onActivityResultAboveL
import android.content.Intent; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultAboveL(int requestCode, int resultCode, Intent intent) {
try {
if (requestCode != FILE_CHOOSER_RESULT_CODE || uploadMessageAboveL == null){
return;
}
Uri[] results = null;
if (resultCode == Activity.RESULT_OK) {
if (intent != null) {
String dataString = intent.getDataString();
ClipData clipData = intent.getClipData();
if (clipData != null) {
results = new Uri[clipData.getItemCount()];
for (int i = 0; i < clipData.getItemCount(); i++) {
ClipData.Item item = clipData.getItemAt(i);
results[i] = item.getUri();
}
}
if (dataString != null)
results = new Uri[]{Uri.parse(dataString)};
}
}
uploadMessageAboveL.onReceiveValue(results);
uploadMessageAboveL = null;
} catch (Exception e) {
e.printStackTrace();
}
}