Questions tagged [android-usb]

Questions regarding the implementation of USB communication on Android through one of the two supported modes: USB accessory or USB host.

Android supports a variety of USB peripherals and Android USB accessories (hardware that implements the Android accessory protocol) through two modes: USB accessory and USB host. In USB accessory mode, the external USB hardware act as the USB hosts. Examples of accessories might include robotics controllers; docking stations; diagnostic and musical equipment; kiosks; card readers; and much more. This gives Android-powered devices that do not have host capabilities the ability to interact with USB hardware.

110 questions
4
votes
1 answer

Bypass android usb host permission confirmation dialog on Android 9

Before Android 9 I could bypass android usb host permission confirmation dialog by using root, systemizing my app and using next usb classes https://stackoverflow.com/a/15378118/7767664 https://stackoverflow.com/a/19681849/7767664 But it doesn't…
user924
  • 8,146
  • 7
  • 57
  • 139
4
votes
1 answer

Show USB permission dialog over Android Kiosk application?

So I have an application that is pinned to the device with startLockTask command and it has several restrictions so the user cannot escape from the application or change settings of the device. However, the user should be able to transfer files…
4
votes
1 answer

how to listen android serial port data in my BroadcastReceiver

I made an application with serial port comminication systems. But i need this. When serial data received, application triggers and opens the screen. I already use USB_DEVICE_ATTACHED but i need something like that action "USB_DATA_RECEIVED". Is it…
Can Can
  • 49
  • 1
  • 5
4
votes
1 answer

unable to write File to usb storage

I am trying to create file dir to connected usb storage I have written following code to create dir : public class MainActivity extends AppCompatActivity { private static final String ACTION_USB_PERMISSION =…
user3997016
3
votes
2 answers

How to programmatically identify if any broken USB cable is connected to the Android charging port?

Is it possible to identify if any USB cable is connected to the charging port of android phone with another end of cable as loosely connected? I'm able to find when device is connected or disconnected from AC/USB power or if any media is mounted or…
Prakash
  • 449
  • 2
  • 4
  • 15
3
votes
1 answer

On-screen keyboard not working when USB barcode scanner is connected

I'm developping a inventory management app, and want to use an kitkat tablet as the end-user device. I use an USB barcode reader which works fine. My problem is that once the barcode reader is plugged in, it's recognized as a real keyboard, and I…
Nazmul
  • 69
  • 1
  • 6
3
votes
0 answers

App installation is cancelled on MI devices every time when instant run enabled

I am testing on XIOMI REDMI note 4, When instant run was disabled it was working perfectly and asking permission when i run the app whether to allow or deny. Then i enabled instant run and app launching is cancelled internally by device, I have then…
Jinansi
  • 31
  • 3
3
votes
0 answers

android: usbManager.getDeviceList() returns empty list after boot

I am developing an application, which uses a usb device through Usb host mode. I use an IntentFilter for ACTION_USB_DEVICE_ATTACHED, so I can connect and communicate with the device after it is attached. The problem occurs when I turn in (or reboot)…
matzahtli
  • 41
  • 5
3
votes
1 answer

Android USB actions(ACTION_USB_DEVICE_ATTACHED & ACTION_USB_DEVICE_DETACHED) not working in BroadcastReceiver

I'm working on a App which has a requirement to listen on USB events (ACTION_USB_DEVICE_ATTACHED & ACTION_USB_DEVICE_DETACHED). I have created a receiver which listens on the these actions. But my receiver is not firing up when any of these events…
3
votes
1 answer

Android not enough storage memory

I created an Android app sometime ago. What the app does is basically download a list of files (images and videos) and play them in a loop (like a Playlist). These files are saved in the default Android External Storage Directory. I get it using…
Ale
  • 2,282
  • 5
  • 38
  • 67
3
votes
1 answer

Activity onCreate() called when connecting OTG device

I am developping an app which uses a OTG USB device. The device I am using is a USB barcodescanner which is detected by android as a keyboard. But I detected that every time I plug or unplug the OTG device, the App is restarted by calling the…
Hermandroid
  • 2,120
  • 4
  • 29
  • 35
3
votes
2 answers

Is it possible to Turn Off USB Storage on Android Devices programatically?

I have tried to search over and over and got confused whether we can have control over USB storage without rooting the phone,if yes than how? I have tried the following method to enable and disable the permission but all in vain: StorageManager…
3
votes
1 answer

How to Connect USB device with my Android device

In the example link given in github am unable to detect my usb device using this example and moreover can anyone tell me how can I specify the device product id and vendor id to device_filter.xml. The main idea of mine to test this example is to…
user3517929
  • 235
  • 1
  • 7
2
votes
3 answers

Using Google EMM how to block the user from formatting the device

We want to block the user from formatting the device. So we have created a custom policy with following options. "factoryResetDisabled": true, "safeBootDisabled": true, This does not work when Policy is enrolled, as when we went to boot-loader…
2
votes
3 answers

Install Via USB not working - on 7.0 device

I have red mi note 4 devices after update device with miui version 9 attempt to enable installation via application via USB, it doesn't work and shows "This device is temporarily restricted". The solution I found didn't work. Without that feature, I…
Sanjay Bhalani
  • 2,424
  • 18
  • 44