简体   繁体   中英

Android and PC Communication over USB: What is a safe directory that I can use ADB push/pull on and access from an Android app?

I am writing an application that will allow an android phone and java application on the computer to communicate over the USB cable. Using Bluetooth or Wifi is not an option in this case.

I found it very difficult to find a nice solution to this problem, and the Host/Accessory libariries seemed designed to hook the phone up to docks/cameras/circuitboards rather than simply a PC. This is my solution, let me know if there are better alternatives:

I'm going to create a Java application to use ADB to push files onto the phone, the phone will then check those files for changes and act accordingly.

It seems to work well so far, except I am using the /sdcard/ folder to hold these files. I want this app to work on phones without SD cards too, so I want to know if there is some other safe folder that I can count on being able to access from the PC with ADB and the android app as well.

(I have looked at INTERNAL STORAGE libraries, but I don't know where they store their data and if I can push/pull with them from ADB.)

Thanks in advance for any help!

Read this https://groups.google.com/forum/?fromgroups#!topic/android-developers/tZrxqZQLh98 Nice discussion about holding tmp files. Do u want to control your application from PC? Cant you use Intents launched by ADB for that?

Another options port forwarding over USB with ADB: adb forward tcp:6100 tcp:7100 adb forward tcp:6100 local:logd

Personally I end-up doing GET requests to my local Apache server to fetch data. Or on rooted device many folders become available.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM