I'm going to run Android app on Chromebook directly to access connected usb devices, not from ARC Welder.
I want to use ES File Explorer to access my usb devices.
Plugin a USB OTG wire and run ES File Explorer on normal Android devices, it can detect connected USB devices as expected.
However, if I run the same ES File Explorer Android app on Chromebook, it can not detect connected USB devices. Looks in this case, Chromebook intercepts USB low level data packages. Because I can use Chromebook built-in File Explorer(which is not an Android app) to access connected USB devices.
By the way, I'm using USB storage to do the test.
So my question is, how can an Android app access connected USB devices on Chromebook? Is current behavior by design? Is there any plan to add USB support for Android apps in the future?
Based on the following Chromium bug report:
https://bugs.chromium.org/p/chromium/issues/detail?id=660189
Summary:
It appears that access to external/USB storage (read and write) for container based Android Apps on ChromeOS (container ARC) is a known issue, appears to be on the roadmap, but behind other priorities.
Update 2017-11-30:
The Chromium team has implemented USB On-The-Go access for the SD card on ChromeOS 62 (Chromium M-61?) or higher. What this means is that developers who expect their apps to work with the SD card as if it was under the battery in their phone will be disappointed. This is due to the fact that a 'hot swappable' SD card such as those found on a Chromebook isn't considered Adoptable Storage by the Android Framework.
Additionally if you want to use the MediaStore APIs to access it, you are still out of luck as the Android Framework does not support access to removable hardware. The Chromium team is aware and considering options:
Old issue ticket: https://bugs.chromium.org/p/chromium/issues/detail?id=789045&desc=3
So what to do?
Use: Android Storage Access Framework
See this Commonware's post on Removable Storage for further details.
Update 2019-09-04
ChromeOS 72 onward is supporting Android's MediaStore API, and direct '/storage' support for accessing content on SD card.
See: https://bugs.chromium.org/p/chromium/issues/detail?id=789045#c98
Issue ticket for supporting Android's Adoptable Storage:
https://bugs.chromium.org/p/chromium/issues/detail?id=917451
Related
I am trying to develop a file communication system that interfaces between the respective file systems of a Windows PC and a connected Android device. I realize a better (or at least simpler) way to do this would probably involve using the adb push and pull commands, but I am gathering options/trying to avoid developing additional communications on the Windows side beyond its basic OS file access. I know it is possible to interact with the device's storage directly from Windows when the device is physically connected via USB - if I understand correctly, this is commonly done using MTP? However, I am also currently constrained to only being able to use an emulated Android device. The Android Emulator is a useful tool for a variety of development situations, but I am not sure it was ever intended to appear as an MTP device in Windows like its physical counterparts do.
So could anyone provide documentation or some other resource establishing either
an MTP, UMS, etc. Windows connection is indeed not possible with the default QEMU Android Emulator; or
it is, and how.
Judging by the answer provided here - https://stackoverflow.com/a/21633596/1399272 - it does not appear that accessing the Android file system using a mounted drive in the Windows file system is an option, regardless of whether it is emulated or physically connected. So my question becomes moot point.
Is there some utility available that will display all the files on an android phone, including local memory and sd card, even if the phone is not rooted?
It could be either some Android app or some PC-based utility that would display the files on a phone connected via USB.
Also, for those of you who develop on android phones, do you do your development and testing on rooted phones?
There's the Android Device Monitor that ships with the SDK. It's integrated into Android Studio and Eclipse.
Let's you inspect the file system and a lot more. I've only ever used it with simulators. Non rooted phones won't display their /data/data directory, from the ones I have. You'd have to root them for that, I believe.
In my Android app I store encrypted files on the SD card and only my app is able to access and decipher them.
However, I need to make those files available for clear transfer to a PC or Mac via the USB connexion.
The idea would be that the user can activate the transfer mode on the app secured by authentication and PIN code. When activated, I would like to create a fake folder tree and files matching the encrypted content on the SD card.
And when the user will try to copy them on his computer, I thought about catching the event and decipher the original file on the fly to allow him to retrieve the original file on his computer's file system.
Does anyone know if that is even technically possible on non-rooted phones?
You could use a USB connection from Android to a computer and then have a client program on the PC and your app on Android talk to each other (no file-system): Android USB-API
This way, you could transfer the encrypted files and decrypt them on the PC.
Pay attention to the hardware requirements though:
USB accessory and host modes are directly supported in Android 3.1
(API level 12) or newer platforms. USB accessory mode is also
backported to Android 2.3.4 (API level 10) as an add-on library to support a broader range of devices. Device manufacturers can choose
whether or not to include the add-on library on the device's system
image.
Note: Support for USB host and accessory modes are ultimately
dependant on the device's hardware, regardless of platform level. You
can filter for devices that support USB host and accessory through a
<uses-feature> element. See the USB accessory and host documentation
for more details.
This would be a low-level implementation.
If I wanted to implement an app for 2 Android devices so I can connect from one to the other via bluetooth, how can I do that via emulator?
HINT: I don't have an Android phone for simulating.
Thanks.
There are few limitations for the Android Emulator. The functional limitations include:
No support for placing or receiving actual phone calls. You can simulate phone calls (placed and received) through the emulator console, however.
No support for USB connections
No support for device-attached headphones
No support for determining network connected state
No support for determining battery charge level and AC charging state
No support for determining SD card insert/eject
No support for Bluetooth
Source Link
I've found the way to debug bt-enabled application on virtual android with real devices. That is not ADK emulator, and it has some flaws, but it definitely works.
Host computer works under Windows 7 64-bit with standard BT stack. Step by step:
Install VMWare Player. It's free for non-commercial usage
Create virtual machine. Set "Other linux 2.6" guest OS type.
Choose reasonable amount of RAM. Remove SCSI disk and printer. Add IDE disk at least 1 GB, keep USB controller, ensure if bluetooth devices are shared with host computer.
Download android installation from android-x86.org. I recommend Android 4.0 RC2 for EEE PC
Point VM's CD to the ISO file.
Start the VM and install android. Unfortunately, it's impossible to add google account there for now.
Switch to android console(Alt-F1 inside virtual machine) and ask for IP address(use netcfg command, look at eth0 network interface), then switch back to GUI(Alt-F7)
On host machine, run adb.exe connect your-vm-ip
Enjoy!
Here is an illustrated tutorial in Russian
You can't use an emulator to test bluetooth apps. The BluetoothAdapter will remain null in emulator. You would need a bluetooth device.
Reference link of accepted no longer exists and I can't seem to find any other pages the mentioned the exact same details. However, it is mentioned in this docs:
What's not supported
The Android Emulator supports most features of a device, but doesn't include virtual hardware for:
WiFi
Bluetooth
NFC
SD card insert/eject
Device-attached headphones
USB
The watch emulator for Android Wear doesn't support the Overview (Recent Apps) button, D-pad, and fingerprint sensor.
While most end users of phones and tablets tend to use earlier API levels, Android Wear and Android TV users tend to use the latest releases. Using recent releases can give you a better experience using the emulator.
In addition to elmot's method (which I have seen on various places on the net and has been reported to work), you may also consider this utility which seems to do exactly what you would need:
https://github.com/cheng81/Android-Bluetooth-Simulator
I am developing an application that has the following requirement:
When the device is connected to a computer via USB, the user should be
able to use Windows Explorer to drag files into and out of the
application directory.
The application will consume some of these files and produces others
which should be able to be copied back to the computer.
The target device does not have an external storage device (for
example an SD Card).
The directories that the files will be stored in should be accessible
whilst the application is running.
I've looked into the data storage page in the android documentation, but none of the methods stated there seem to do what I require.
Alternatively, is there a way to select the computer when the application is running and 'send' files via USB to the computer? How about for 'receiving' files?
What is the best way to fulfill this requirement?
When the device is connected to a computer via USB, the user should be able to use Windows Explorer to drag files into and out of the application directory.
If "the application directory" refers to a spot on external storage, this is possible.
The application will consume some of these files and produces others which should be able to be copied back to the computer.
If this is supposed to happen simultaneously, the device must be running Android 3.x or higher. Android 1.x and 2.x did not support simultaneous access to external storage.
The target device does not have an external storage device (for example an SD Card).
It needs to have something designated as "external storage". That does not have to be removable storage. On Android 3.x and 4.x, it is usually just a part of on-board flash that was designated to be accessible as external storage. In Android terms, "external storage" means "can be accessed by a host computer using USB and by all applications on the device as well".
The directories that the files will be stored in should be accessible whilst the application is running.
Again, this requires Android 3.x or higher. If this is a custom device, that most likely means you are going to need to use the recently-released Android 4.0 source code.
Alternatively, is there a way to select the computer when the application is running and 'send' files via USB to the computer? How about for 'receiving' files?
No and no, respectively.
What your going to want to do is use Environment.getExternalStorageDirectory. Even if there is no sd card, most android devices partition a part of the on board memory to be used as external storage.