有没有检测到pc usb连接(而不是通过充电器)火狐操作系统设备在盖亚层?
盖亚层中的任何回调也适用于我。
我这么做的原因是,当设备通过USB连接到pc时,我需要处理一些事件。然而,到目前为止,我还没有找到任何线索。
发布于 2013-12-09 18:46:29
认证的应用程序可能有更好的方法来做到这一点,但是对于特权应用程序来说,一种方法可能是在sdcard上使用一个更改监听器--只有在设置中启用了USB存储选项时,这种方法才能工作。
var sdcard = navigator.getDeviceStorage('sdcard');
sdcard.addEventListener("change", function (event) {
var reason = event.reason;
//if reason is "shared" you know you are connected
//if reason is "available" you know you are not connected
});确保向清单中添加设备存储权限。
"device-storage:sdcard": {
"access": "readwrite" //could be read only
}https://stackoverflow.com/questions/20464938
复制相似问题