Domanda

I am using the blow code to copy image to clipboard but when i am trying to past it in another application so only the path is paste not the image.

    private void copyImageToClipBoard(File mFile1) {
    ClipboardManager mClipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
    ContentValues values = new ContentValues(2);
    values.put(MediaStore.Images.Media.MIME_TYPE, "Image/jpg");
    values.put(MediaStore.Images.Media.DATA, mFile1.getAbsolutePath());
    ContentResolver theContent = getContentResolver();
    Uri imageUri = theContent.insert(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    ClipData theClip = ClipData.newUri(getContentResolver(), "Image",
            imageUri);
    mClipboard.setPrimaryClip(theClip);
}

I have checked so many post on this but still not getting desire solution. Can any one tell me please how to do it?

È stato utile?

Soluzione

I search the developer.android.com but I haven't found any method for you are looking. I think Copying Image from Clipboard is not possible in Android. I think there is no indication that such functionality is supported in Android. The behavior is correct and the uri is the copied data not the bitmap. It depends on whether the place you are pasting in can handle this uri.

Altri suggerimenti

I think, when you get path to image from clipboard that it is enough. When you have path you can handle this however you want for example load image like Bitmap and show in ImageView for example like this: BitmapFactory.decodeFile("path of your image");

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top