Intent setClipData - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Intent setClipData method.

This code example shows how to use the following methods:addFlags, putExtra, setClass, setClipData
    @SuppressLint("NewApi") 
    public static Intent createChooser(Intent target, CharSequence title) {
        if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
            return Intent.createChooser(target, title);
        } 
        Intent intent = new Intent();
        intent.setClass(Application.getLastInstance(), ChooserActivity.class);
        intent.putExtra(Intent.EXTRA_INTENT, target);
        if (title != null) {
            intent.putExtra(Intent.EXTRA_TITLE, title);
        } 
        int permFlags = target.getFlags()
                & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        if (permFlags != 0 && VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
            ClipData targetClipData = target.getClipData();
            if (targetClipData == null && target.getData() != null) {
                ClipData.Item item = new ClipData.Item(target.getData());
                String[] mimeTypes;
                if (target.getType() != null) {
                    mimeTypes = new String[]{

9
CodeRank
This code example shows how to use the following methods:getCacheDir, getUriForFile
     * channel, since hi-res Bitmaps are too big to serialize into a Bundle. 
     * This file will be passed (as a uri) to other activities (such as the gallery/camera/ 
     *  cropper/etc.), and read by us once they are finished writing it. 
     */ 
    public static Uri generateTempImageUri(Context context) {
        return FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY,
                new File(pathForTempPhoto(context, generateTempPhotoFileName())));
    } 
 
    public static Uri generateTempCroppedImageUri(Context context) {
        return FileProvider.getUriForFile(context, FILE_PROVIDER_AUTHORITY,
                new File(pathForTempPhoto(context, generateTempCroppedPhotoFileName())));
    } 
 
    private static String pathForTempPhoto(Context context, String fileName) {
        final File dir = context.getCacheDir();
        dir.mkdirs();
        final File f = new File(dir, fileName);
        return f.getAbsolutePath();
    } 
 
6
CodeRank
setClipData Method Overview
Set a ClipData associated with this Intent.
See Code Examples for other Android Intent Methods: