Android: Automount mass storage issue when plugging USB cable - android

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)

Related

Android Tablet is restarting by itself

I have a custom android tablet and we have created an application which is used for home automation.I have installed the application in it and it works fine. I got the comments from the client saying that the tablet restarts by itself at night. I tried to catch the log by connecting it to eclipse but it didnt happend here. Will the tablet restart by itself under any circumstances ? , The tablet is a samsung ARM with 512mb ram and 4gb sdcard in it which runs on android version 2.2.
You have not provided any code, which leads me to assume the following. Unless you have the permission of PowerManager, you app has no control over the device's off/on state.
You also mentioned, on testing, you were not able to pinpoint the issue that the client talked about. This is very important information, and it helps strengthen my conclusion. Again, if the above criterion is correct (you don't have powermanager) then, it could be the clients tablet is just messed up...
The reebooting is actually a common problem:
http://forums.androidcentral.com/samsung-galaxy-tab-pro-8-4/453390-why-my-tablet-randomly-rebooting-resetting.html
Here, user B. Diddy states:
It's hard to say. Random reboots can happen because of problems with
the firmware, but can also be due to some app you installed that is
making the system unstable, or perhaps some bad bit of data that is in
the system cache. A corrupt SD card can also cause problems. Here are
some things you can try:
Unmount your SD card in Settings>Storage, remove it, and reboot. Use the tablet for a while (like a few days) without the SD card and
see if the random reboots recur. If they don't, plug it back in again,
and see if the reboots start again.
Boot into Safe Mode, which temporarily disables all 3rd party apps: Safe mode: Samsung Galaxy Tab 4 | T-Mobile Support. (I couldn't find
steps specifically for the Tab Pro, so I'm assuming the steps for the
Tab 4 are the same.) This might not be an effective troubleshooting
method if the random reboots don't occur very often, because it's hard
to expect anyone to use their tablet for several days in Safe Mode,
thus being unable to access any of the 3rd party apps you installed.
Boot into Recovery Mode and wipe the cache partition, which doesn't erase any personal data. Follow the steps in this video, and make sure
you select Wipe Cache Partition, and not Wipe Data/Factory Reset.
So, let me know if your app uses the PowerManager permission. If it doesn't you're good to go, and it is probably a faulty tablet.
Ruchir

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

Enable the SD Card while USB Debugging?

I am developing a phone app and I'm testing it with my Droid RAZR with OS version 4.1.2
I need the phone to be able to use its SD card, and prevent the computer from using the USB connection as a "mass storage" connection, which causes it to take over the SD card (it can only be mounted to either my phone or the computer, not both).
You used to be able to connect to the computer in "Charge Only" mode, which would keep the SD card active with the phone, but that no longer seems to be an option. There is only Mass Storage (computer uses SD card), Media Device (same story), and Camera (same there too).
Is there another option? Perhaps some way to disable the mass storage from the PC's side but still retain the USB Debugging?
Take a look at this thread here. As stated there:
Next, enable USB debugging by checking the “USB Debugging” item.
Finally – and this is the most oddball – you need to go back a screen,
to Settings, and click on the Storage item. Up in the upper right of
the screen are three tiny squares which represent the Jelly Bean way
of doing a context menu. Click that, and a small “USB Computer
Connection” item will appear. Click that. You’re taken to a new
screen with two “Connect As” options.
Check “Camera”. Yes, because USB debugging requires the use of a
camera (no, not really). It’s just a requirement. Something about
the communication protocol or file transfer encoding or something. I
don’t make this stuff up.

Where do I find app data in Android

My goal is to save data from app in a text file for further analysis. I used the exact code as given here for saving data:
The data is stored and retrieved according to the app, but I am not able to find MySampleFile.txt (even using the search functionality) on the phone.
I can't find it in Android -> data -> com.*.*. I have a Samsung Galaxy S3. Is anything different in this phone?
Should I make any modifications in the phone?
Do the following to be able to see your data stored in the phone's internal memory.
Turn on USB Debugging on your phone.
Connect your phone to the system.
Open DDMS perspective in your Eclipse.
Select your device from the devices tab on the left.
On the right, the last tab will be File Explorer. Open that.
Traverse to data/data/your.app.package to find the data you want to see.
P.S:- NEVER root your phone, unless you're a developer who loves to mess around with the System apps.
To see data, you phone must be root. Samsung Galaxy S3 is not a root from vendor, you need to root your phone to access internal memory/storage, you can only access external memory/storage in your phone i.e. sdcard
But, i would suggest you to use Emulator rather root your phone.
Here, are some links about what is rooting, you can go through these:
http://gizmodo.com/5982287/reasons-to-root-your-android-device
http://lifehacker.com/5789397/the-always-up+to+date-guide-to-rooting-any-android-phone
http://en.wikipedia.org/wiki/Android_rooting
But again I would suggest to use Emulator unless you are not expert enough to root and Install firmwares again when you don't want your phone root.
Please use Emulator to see data->com.package
From Windows Menu->ShowView->Others->android->fileExplorer you can see the file in your device
Specify permission in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

How to set the Usb connection mode?

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

Categories

Resources