I am trying to transfer files from my android emulator to my server. I observed that files of size around 2MB or greater are just not getting transferred.
Is it because of the internal memory I've provided to the emulator. If it is, should I change the way I'm transferring the file? My transfer method is similar to the only here: Android:How to upload .mp3 file to http server?
Yes, I found the answer. I had to make a change in the PHP ini file and increase the limit to my desired size :)
So there is nothing wrong with the emulator as such, it was a problem at my webserver end.
Related
I'm building my first Android app and have run into a little problem. Using AsyncHttpClient to download Pdf files I get
"E/dalvikvm-heap(30871): Out of memory on a 21893326-byte allocation."
errors on anything larger than 15 Mb. Files up to 15 Mb download just fine. Are there any settings that can resolve this?
Thanks in advance for your help!
Are there any settings that can resolve this?
Not really. Assuming that you are using BinaryHttpResponseHandler, it will give you the entire file in memory, which will not be possible for larger files.
You would need to create your own version of BinaryHttpResponseHandler with a modified sendResponseMessage() method, one that streams the results directly to a file. Or, find another HTTP client library that does this for you.
this is most probably not really android related, but in my game users can download content via akamai cdn. this works nicely except for jpeg files which for some users are delivered with a different compression. this is somehow depending on the device / android build version / provider / location (and therefore actual akamai node).
since i do a hash check after download to check if the file was delivered properly i get a different hash for a manipulated jpeg file and detect an error.
i already changed the download process so that all files are named
filename_ext.bin
so that the mime type would be application/octet-stream instead of mage/jpeg, but still it seams that some node in the middle ( a proxy maybe? ) checks for the file content and recompresses the jpeg (to save 10-20% of jpeg size; after all, cpu power is cheap, bandwith is expensive).
does anyone have any experience with this kind of problem?
maybe a solution would be to zip every file and unzip on the device ( hoping that whatever is altering the file does not unzip / change jpeg / zip again).
thanks in advance.
ok, just got answer from akamai support:
"some providers have transparent proxies installed that dynamically re-compress image graphics (jpg and gif) - they also modify HTML pages. Images are recognized based on their file signature and not based on file extension."
so I actually have to encrypt / zip the files to circumvent that...
also:
http header
Cache-Control no-transform
also did the trick.
In my project I am using custom android devices and I have to encrypt all the files on my sdcard for security. I am using AES-128 bit encryption, but it takes too long to decrypt and open the files.
For the videos I have used on the fly decryption using CipherInputStream and CipherOutputStream and a proxy server. Is this possible for big pdf files?
A 12 MB pdf file is taking around 40 seconds to decrypt so opening the file after completely decrypting it is not an option. Also, I do not want to save the decrypted files anywhere on the device. Is it possible to open parts of pdf files as done with videos?
I tried using the full disk encryption in android but it did not work on my custom devices and showed only a green droid, after which nothing happens.
Thanks in advance.
If you just encrypted the whole file and your viewer app/library expects to get a whole file, not really. If you used PDF encryption, which encrypts each object inside the file, you could decrypt and display them on demand.
What exactly are you trying to achieve here? Are those files part of your app? If you just want to protect data on the SD card, there are ways to do this automatically, but they require a rooted device. For example LUKS Manager.
Earlier I was testing on the emulator. On actual device the time taken to decrypt is much less(~6sec for 12 MB) and acceptable.Finally I did the following :-
For videos and audio I used streaming to mxPlayer. For the big files which cannot be shown in parts I encrypted only parts of the file. Encrypting around 10MB of the file makes it unusable.
The files are saved to some hidden temporary location which is deleted once its no longer required.
Still proper apps are required on the device so that Android can detect them and open them when required. Like some video players didn't work when opening video from my application but mxPlayer did.
I have approximately 80MB+ mp3 files,40MB images in my project.when I try to put 3MB of each these files eclipse takes a lot time to build.is it possible to put all these files in Raw or assets folder?what is the solution to make eclipse build fast.
I think for best practice is to make the user download these files after he installes your app since Android market limits your app size to 50MB.
You can use
AsynTask to download the data asynchronously
I have this same issue, and came to the same conclusion as khr2003. I just want to add that the real limit for Android Market is more like 30MB since an app larger than that is impossible to download to most phones -- you will get out of storage errors.
I have 11 videos to include in my App. Each of them is around 9MB. Besides those, I have to a few sound files and image files in the app. Therefore the app size is going 100+MB. Is there any way to accommodate all the files so that app size does not become an issue for me?
Download the files after starting the app for the first time.
Puh..that's quite large. In such a situation I'd
Let the user download your app not containing any videos/audio files that cause the large size
At first run guide the user through a wizard where you download the additionally needed files to the SD card.
Still, downloading nearly 100MB won't be ideal, but better than directly download all of it at the first install. (IMHO)
The most common sollution i've seen is downloading them during the first run of the programme. Just check if everything is available, and if it isn't, download the needed files.
pros:
This way you can also add video's on the fly.
APK size stays small so initial download is quick
Cons:
after downloading the app you can't directly use it: content must be downloaded first
I would suggest you to put them in the assets folder, so they will not be compressed.
This way you'll have problems testing your project with eclipse, so try building it with command line, and then install on device with adb
In my scenario, I had 300+ videos, totalling upto 400+ MB of the size.
I checked with few of them and deployed the app the way i just told.
may not be the best way around, but may work.
You can upload into youtube or make your own simple video streaming server