当前位置: 首页>>代码示例>>Java>>正文


Java Intent.getClipData方法代码示例

本文整理汇总了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;
    }
 
开发者ID:burakgumusfb,项目名称:Android.Media.Uploader,代码行数:23,代码来源:Helper.java

示例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;


    }
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:25,代码来源:FileUpLoadChooserImpl.java

示例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);
        }
    }

}
 
开发者ID:benlau,项目名称:androidnative.pri,代码行数:18,代码来源:VideoPicker.java

示例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);
}
 
开发者ID:benlau,项目名称:androidnative.pri,代码行数:17,代码来源:VideoPicker.java

示例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);
        }
    }

}
 
开发者ID:benlau,项目名称:androidnative.pri,代码行数:18,代码来源:ImagePicker.java

示例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);
}
 
开发者ID:benlau,项目名称:androidnative.pri,代码行数:17,代码来源:ImagePicker.java

示例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;
}
 
开发者ID:JunGeges,项目名称:AliZhiBoHao,代码行数:24,代码来源:WebActivity.java

示例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;
}
 
开发者ID:kwmt,项目名称:WebViewInputSample,代码行数:39,代码来源:FileChooserWebChromeClient.java

示例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;
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:29,代码来源:x5_MainActivity.java

示例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;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:11,代码来源:ReceiveShare.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:RemoteInputCompatJellybean.java

示例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;
}
 
开发者ID:marchinram,项目名称:RxGallery,代码行数:15,代码来源:RxGalleryActivity.java

示例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();
    }
}
 
开发者ID:lennyup,项目名称:react-native-udesk,代码行数:29,代码来源:UdeskWebChromeClient.java


注:本文中的android.content.Intent.getClipData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。