How to set the Usb connection mode?
Asked Answered
U

5

6

I'm writing an application which is supposed to dump data on the SD card and then another application on a pc which should read the data when the device is connected to the pc (in disc drive mode). On my HTC Legend there is a dialog to choose between: Charge only, HTC Sync, Disk drive..

Is there a possibility to set the mode with which the device is connecting to the pc or at least an intent to ask the user to switch the mode?

Undamped answered 18/1, 2011 at 9:42 Comment(2)
Did you ever figure this out? Or did you find a way to pull up the activity that the system uses to switch modes?Standoff
No I didn't find any way to do it. And I didn't try to call the manufaturer switching activity. I had to switch phones and it was not a sustainable solutionUndamped
T
0

I haven't found a way of setting the mode programmatically, but I believe you can bring up the settings menu programmatically by invoking the same activity that the system invokes from the notification area. Unfortunately this appears to be manufacturer-specific: on my phone it is com.htc.android.psclient.SwitchUsbSettings.

Tearing answered 6/3, 2011 at 14:22 Comment(1)
com.htc.android.psclient.SwitchUsbSettings is an internal activity and can't be called. If I'm not mistaken...Undamped
I
0

On HTC devices, open the ConnectToPC service (whilst USB is not plugged in) in Manage Apps (ICS - probably applies to Gingerbread too; don't remember), and hit Clear Data. Then, plug the USB back again, and you should have the option to "Don't ask again" available. Select your desired mode, check the box, and accept.

Insomnia answered 28/2, 2012 at 4:4 Comment(2)
The question is about a programmatical solutionUndamped
Although it's not an answer the programming question, it's the only place I've been able to find the answer to doing this.Labe
C
0

CompanionLink does this when you request a USB sync in their android app: it flushes data to SD, then exports the SD as storage (a "disk drive") on the USB, then waits for the user to manually signal the android app when the PC is finished using the SD, and then undoes the SD export to USB again. Though the CompanionLink app can be very frustrating to use, at least this part of it is (largely) reliable.

Unfortunately I don't know the technical details, may well need to figure them out myself one of these months. If you can't get any traction with android docs, perhaps you could study what CompanionLink does on android to implement this. The sequence I describe above is when it is configured to sync over USB against a (PC-based) Palm Desktop.

As an aside, it appears that the reason for this highly-convoluted process is that the SD card's FS is accessed directly and at least the presently-used card FAT FS can only support a single client: the phone itself or USB. imo it would be extremely helpful if concurrent shared access to the SD were possible, but this would likely require deep android changes.

Cowart answered 4/1, 2013 at 0:27 Comment(0)
R
0

For anyone having this issue with an HTC One M8, this is a bit off the wall, but makes the point to think outside the box. A USB connection resulted in the device charging, that was it.

The solution was the combination of a different USB cable, uninstalling an application called Battery Doctor (which apparently likes to manage everything around your battery), AND USB Network Setting - turn ON Smart Network Sharing...Seemingly unrelated...but this combination got my connected with MobileGo for Android to manage and back up files,contacts and settings.

Hope this helps someone.

Rearrange answered 1/1, 2015 at 0:36 Comment(0)
L
-2

Yes .In Android there is a way to change the behaviour of the devices`s USB mode when the device is connected with the PC. I used a Motorola Milestone[running 2.1] and i was able to switch between the following modes : PC Suite[developed by Motorola],MemoryCardAccess and Charge alone. If you need to access phone memory I think you should turn ON "USB Debugging Mode " in your device.Am not sure about it though,I feel it may be handy !!

Levitical answered 18/1, 2011 at 10:16 Comment(3)
Yes but your answer would be more helpful if you told me how you did it.Undamped
Turn on "USB Debugging" on your device. On the device, go to the home screen, press " MENU, select Applications > Development, then enable USB debugging"Levitical
I don't know what you are talking about. Of course I have USB debugging turned on, I'm developing an Application... My question was if you could switch the USB connection mode programmatically. I guess you can'tUndamped

© 2022 - 2024 — McMap. All rights reserved.