Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

How to copy Images/files to clipboard in android? Any Alternative methods/steps to get this

I want to copy images/files to clipboard. I have googled it but i didn't find any alternative/suggestion to this. but i have seen some app's done in app store. want to know how can we achieve this.

Any one please help me OR give me some suggestions?

i found this link but now clue how to achieve this functionality.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For the details of how to copy/paste image/file in Android, read Android official document from here.

In short, copy/paste image/file follows the below steps:

  1. The data source(the application where you copy data from) should create a ContentProvider and generate a Uri which can be used to retrived the image/file. The Uri looks like content://[application package name]/path/to/file
  2. The data destination(the application where you copy data to) get the Uri from ClipboardManager and user ContentResolver to retrive the image/file.

As you can see, the copy/paste can only be achieved when the two applications work together. Unfortunately, most of the Android applications haven't follow this rule.

For example, the Google docs Android app, when you copy an image in Google docs, it will generate an invalid Uri. You can't imagine even google itself does not follow Android official copy/paste rule.

And I have tested many main stream editor applications, including Microsoft Word, evernote, they even don't support copy image.

Through my test, I found copy/paste image/file works on some Samsung Android phones(You can copy image from in-stock browser into the message application on Samsung Galaxy Note3). However, Samsung does not follow Android copy/paste framework. They implement the copy/paste using their own mechanism which means 3rd party applications can not access the clip data.

Hence, I think there is still a long way to go, for Android applications to follow the Android official copy/paste framework.

To talk about your requirement, I guess you want to behave as the copy data source. Although your own application supports copy, as long as copy data destination application does not follow copy/paste framework, you can't accomplish the paste action.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...