Detect USB OTG mass storage device mount

1,064 views
Skip to first unread message

Tim Hessenmüller

unread,
Mar 16, 2016, 8:07:41 AM3/16/16
to Automate
I recently bougth an USB OTG adapter so I could have a lot of storage space for files I dont need that often but I still wanted to have acces to without a computer. And since I love to Automaten things I quickly started to do some stuff with Automate :) Now I've come across the problem that I want to detect when the storage device is plugged in to the phone. I've tried using Storage media mounted?, File Monitor (on the mounting path) and Receive Broadcast with Docking event and all the media events but I couldn't geht any feedback regarding the USB mass storage device.
Is there anything I missed or I could try?

Appreciate the help :D

Henrik "The Developer" Lindqvist

unread,
Mar 16, 2016, 3:22:43 PM3/16/16
to automa...@googlegroups.com
The "android.intent.action.MEDIA_MOUNTED" broadcast, i.e the Storage media mounted block, should be it:
http://developer.android.com/reference/android/content/Intent.html#ACTION_MEDIA_MOUNTED

Try the "android.hardware.usb.action.USB_ACCESSORY_ATTACHED" broadcast:
http://developer.android.com/reference/android/hardware/usb/UsbManager.html#ACTION_USB_ACCESSORY_ATTACHED


Tim Hessenmüller

unread,
Mar 16, 2016, 5:35:34 PM3/16/16
to Automate
Thanks for the quick help. Both ways worked now. Maybe I messed something up when testing before.
Reply all
Reply to author
Forward
0 new messages