开发者

Locate Bluetooth Inbox

开发者 https://www.devze.com 2023-02-13 05:59 出处:网络
Our app needs to grab certain files from the Bluetooth inbox after they are pushed from an external hardware device. Is there a way to programmatically find the Bluetooth folder location? On the Galax

Our app needs to grab certain files from the Bluetooth inbox after they are pushed from an external hardware device. Is there a way to programmatically find the Bluetooth folder location? On the Galaxy it's /mnt/sdcard/bluetooth, and on the Desire it seems to be 开发者_如何学运维/mnt/sdcard/downloads/bluetooth.

Thanks!


As far as I can tell, there's no simple and easy way to do this via the APIs (although there should be!)

Two solutions that could work (depending on the usage context; the first one seems generally better):

  1. On start-up, you app checks if there's a SharedPreference (e.g.) "bluetoothLocation". If it doesn't find it, the app searches either (a) the FS or (b) the FS rooted at /mnt/ (probably (b) is better) until it finds a File such that:

    • The name.equals("bluetooth"), and isDirectory().

Then it saves the path, and there you go. Alternatively (depending on the context) you could,

  1. The first time your external device connects, it sends a file with some long, hard-coded filename (e.g. greoermmvemoper190erjvw0j9e2.txt). Then your app searches through the FS until it finds a file with this shared, hard-coded name, and saves that location.

These are both far from perfect, and their viability depends on your context. I thought I'd throw it out there. Hope it helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消