transfer files from android to computer via usb pr

2019-01-25 16:08发布

I am looking for a solution which uses Android API to transfer a text file from an Android powered device to a computer through USB cable. I have found USB host but I cannot use this because the computer can not act as a device for the Android host.

Do you have any suggestions how I can achieve this?

标签: android usb adb
3条回答
爷的心禁止访问
2楼-- · 2019-01-25 16:31

You can write an app which will use http to contact your pc and send (POST) data to a known endpoint.

Keep in mind that the app will only have access to the data belonging to the app. You will not be able to access an arbitrary file from the file system

查看更多
迷人小祖宗
3楼-- · 2019-01-25 16:41

I have solved this problem by using adb status-window to continuously check for device status, and when a new device is connected, the required files are transferred to the computer using adb pull command.

In order to achieve a portable solution (i.e. to run independently of Android platform), I just copied the files 'adb.exe' and 'AdbWinApi.dll' into my application and used the adb from there.

查看更多
该账号已被封号
4楼-- · 2019-01-25 16:52

Had similar problem where a software installed in PC needed to be able to access file inside the android phone through USB. After long research here is what worked for me (not sure if this is the best solution but it worked). Windows has Windows Portable Device(WPD) API which can be used to enumerate contents of a device through USB (and copy files between client and device).

There are few implementations in java http://code.google.com/p/jmtp/ (works well but doesnt support copy function from device to pc though there is some support available to do this with source code) another one is jusbpmp (available in google repository) (if somebody finds a well documented and maintained implementation do share)

but since jmtp didnt work for me (copy function source compilation(for 64bit OS) failed), wrote C# program from scratch to copy files from device to PC. here is a nice tutorial http://cgeers.com/2011/08/13/wpd-transferring-content/

查看更多
登录 后发表回答