How to set the Usb connection mode? - android

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?

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.

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.

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.

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.

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 !!

Related

Recovering files from a phone with a broken screen (completely black, touch screen unavailable)

I have a Samsung A50.
And I dropped my phone and now the screen is all-black and touchscreen is not working at all.
Tried to look for solutions to recover my files from internal storage(SD card is fine, don't need to worry about it.)
I've had this device for quite a bit now, and I don't know if I enabled USB Debugging from Dev Options some time ago(seems to be resounding no from checking with connecting it to my laptop). And my current laptop right now is new so, it could've have had a past connection that allowed it to transfer files on (the phone would have to prompt to do so.)
I came across adb.
Checking the devices yield that the device is unauthorized (must be from me not being able to press on that prompt huh?). I was wondering if there's anything I can do to access my A50's files from here.

Android development with no screen

I have a hobby android app idea that basically just uses Android's sensors and logs them long term for several days (external battery). The sensors needed are in $200 phones, and I can get ones for under $100 if the screen doesnt work.
My question is, is it pretty easy to make an app that starts and loads via debugging, keeps running when disconnected and when I connect I can extract the log file, or would this so be difficult I would be ahead just to spend the extra $100?
As mentioned, turning on USB debugging without the screen isn't possible. You can't enable USB debugging over USB for security reasons, so your only option would be to use hardware commands to put the device in firmware download mode (presumably it will have a way to do that), then load a custom OS which allows USB debugging by default.
Personally I think that's more than $100 worth of work, so I'd just go with the working device. Then you can use it for other stuff down the line.
Alternately, you can probably get a replacement screen for not too much, and for most devices changing the screen is relatively easy. I'd look into that option as well.
The first barrier you may find is that you must activate the Developer Options in the settings and the USB Debugging. And when you connect to the computer, you must accept that cumputer as the Debugger.
I don't know if it's possible to do it without a working screen.
App will keep running & yes you can can extract the log file when connecting again.
But the problem is in the first step. if your screen if not working, then how would you add your workstation as a trusted device in your "display not working device". I doubt if there is such way, because we need to do several things like switching on developer options, usb debugging etc.
I hope you got your answer.

Android: Disable mandatory restart when changing SIM-cards

For an app that I am currently developing we want to read data from the SIM card of the user, which works fine. We want to make it possible that the user can switch the SIM card while the app is running. While doing this the OS request a device restart and we cannot seem to suppress this message.
Is there a way to make it able to insert a SIM card while the app is running without restarting the device. I'm open for all options (rooting, custom rom, etc...)
I don't think it's possible - I never saw any option in phone settings allowing to turn on or off this feature. What might interest you is that for some phones - for example Sony Xperia Z as far as I remember - phone allowed changing SIM card without restart.
I found a method but i don't know if it'll work with other devices.
Device:Sony E4g(2003)
Android:4.4.4
Root required :yes
Apps Needed :Romtoolbox pro
First open rom toolbox and go to app manager, then search for "Sim Detection" it is a system app, then click it and go to "advanced freeze option" then You Disable "SimDetectionReciever" and you're Done.
Hope this helps

Android: Automount mass storage issue when plugging USB cable

I'm developing an app that makes file downloads, handles lists, contains a map, and so on.
My problem appears when I use a device that has the automount mass storage option activated.
If, at some moment, while running my app, I plug in the USB cable for some reason (charge, copy pics while app is in background, see app logs etc), the mass storage is mounted automatically and all my activities are recreated and my app status is lost.
OK, I could keep some data in DB/preferences in order to be able to restore it, but it's not ok to keep each variable in DB or preferences.
I know that there is an option is settings where I can uncheck this option, but I cannot ask this to every user that will use my app.
I also tried to find a solution to programatically uncheck the automount setting, but I couldn't find one.
I ran out of solutions. Any idea is more than welcome.
Thanks.
Checks the apps you have installed.
Some apps automount your USB storage (AFAIK, doubleTwist and Winamp do this)

How to mass install software to Samsung Galaxy Tab 10.1

our company bought 50 Samsung Galaxy Tabs for corporate use.
Before these can be delivered to users we must install some company labeled programs in to them.
We thought the easiest way to do this would be through ADB but it needs the USB debugging to be enabled. Is there a better and faster way to do it than enable it on each device one by one? Is it possible to enable USB debugging from PC using some program or piece of code while connected with USB cable?
The ideal solution would be that we connect multiple devices via USB to one PC and run installation script that enables USB debugging, runs installations, disables USB debugging and finally shuts down the devices. How would you do this?
Br,
Tupe
Is there a better and faster way to do it than enable it on each device one by one?
Have several people enable it on each device one by one in parallel.
Is it possible to enable USB debugging from PC using some program or piece of code while connected with USB cable?
Fortunately, no, as that would be a security hole.
The ideal solution would be that we connect multiple devices via USB to one PC and run installation script that enables USB debugging, runs installations, disables USB debugging and finally shuts down the devices.
Under your plan, a piece of Windows malware could detect that an Android device is plugged in and install Android malware on that device. After all, if your "installation script" can do it, so can the malware.
How would you do this?
Host the APK on an internal Web server, generate a short URL to it, check the "allow non-Market installs" on the device, and fire up that URL in the browser on the device. This presumes that you plan on updating the app (e.g., bug fixes) and that you aren't planning on going through your whole USB cable process for each of those updates. In that case, you need to get the Web server configured for APK files and have the "allow non-Market installs" checkbox checked anyway, so you may as well do that as part of the initial device setup.
Is it possible to enable USB debugging from PC using some program or piece of code while connected with USB cable?
Hopefully not. If this were possible any piece of hardware that you plugged your device into could do some very nasty things to it without any chance for you to intervene.
I've done some large installs like that. I've not found one technique to be the end all be all.
I would suggest host your apk file online somewhere make a shortened (easy to type) url to it.
Then on the devices open up browser and type the url. That will download your apk, when you click the download complete in the notifications it will start the install.
Note: You will have to turn on "Allow install from unknown" in settings. The fastest way I think is just do the download and press the apk, this will throw up a dialog that has a button you can press to take you right to the correct settings page to turn this on. But bad news is that after you turn it on the install won't resume automatically. So you either have to find the apk with file explorer, or go back to browser and download a new copy of it. I would guess the latter might be quicker, albeit messier.

Categories

Resources