當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。