Android :: OutOfMemory Exception When Loading Bitmap From External Storage

Nov 5, 2010

In my application I load a couple of images from JPEG and PNG files. When I place all those files into assets directory and load it in this way, everything is ok:

CODE:..................

But when I try to load the exact same images from sd card, I get an OutOfMemory exception!

CODE:..............

This is what I get in the log:

CODE:...........

UPDATE: Tried both of these on real device - it seems that I can't load more than 12MB of bitmaps into whatever is called "external memory" (this is not an sd card).

Android :: OutOfMemory exception when loading bitmap from external storage


Android :: OutOfMemory Exception In OnCreate

Oct 2, 2010

I'm having a hard time resolving a crash report. It's an OutOfMemory exception that occurs during the setContentView in the onCreate of my main activity.

I just want to be sure I understood Android LifeCycle well :

1) The onCreate of my main activity is called once and only once during the life time of my application ? Is that correct ?

2) Just like for the big bang, before the oncreate of my activity, nothing exists for that activity, so memory consumption is zero, no objects exists right ?

So what can cause that sometimes, with random framework and devices, I get an OOM exception ? I mean if say my background image is causing this, it should blow up everytime, on every device, shouldn't it ? I mean the result should be reliable.

The background image is a standard jpg : 360*480 weighing 37kb, nothing fancy really :s

The crash report below :

CODE:.....................

View 8 Replies View Related

Android :: Bitmap OutOfMemory On Multiple Screen Changes

Aug 10, 2010

I have a bitmap that I load from the SD card by allowing the user to choose a picture to display. Once the bitmap is created, I set the Bitmap in an ImageView:

CODE:.........................

This works fine. But, if I change the screen orientation from portrait to landscape, and back again a few times, I always get an OutOfMemory exception.

In onPause, I call mBitmap.recycle(), and then on onResume, I call the above code again to create the bitmap and set the ImageView. Since I'm recycling the image each time, how can I get an OutOfMemory error?

In any case, since that failed, I found a post that said to try using onRetainNonConfigurationInstance() and getLastNonConfigurationInstance(). See post http://stackoverflow.com/questions/3250987/save-cache-when-rotate-device/3252547#3252547. I changed my code to work this way, and I still get an error. Changing the code, I had the call to getLastNonConfigurationInstance() in onCreate(), and removed all code in onPause and onResume. provide some way to simply load an image, and then be able to pause and resume the Activity without running out of memory?

View 3 Replies View Related

Android :: Launch My App - It Crashes With OutOfMemory Exception

Aug 24, 2010

I have an Android app that in the onCreate() method, preloads a lot of graphics.

When I test my app on my HTC Aria and launch it, it runs fine. However, if I press the back button to exit my app, and then launch the app again, it crashes with an OutOfMemoryError: bitmap size exceeds VM budget. If I then launch the app for the third time (right after it has crashed) it launches fine. Then if I close and re-launch it, it crashes again with out of memory. It continues this every-other-time-crashing pattern forever if I keep trying.

I checked to see what life cycle methods were being called and onStop() and onDestroy() are both being called when I exit the app, yet I have a feeling that something is not yet being cleaned up and that by "crashing" the app when I try to launch it the second time, it somehow free's the memory.

Any thoughts on what could be happening or how to remedy this? Please let me know if you need me to post more info.

Info: My app is fairly simple and only has 1 activity that plays some frame animations.

View 3 Replies View Related

Android :: Different Bitmap Wallpaper For Every Home Screen - OutOfMemory

Jul 23, 2010

I am trying to set a different wallpaper for every home screen, but I get OutOfMemory issues. I have 5 Bitmaps which I am trying to overlay on a wallpaper Bitmap which is 5 times the display width. Using the code below I get OOM. The problem seems to be the first line of code which creates the large wallpaper Bitmap. My question is whether there is a way to do this (i.e. some way that takes up less memory, or someway to allocate more memory?).

CODE:.......................

View 1 Replies View Related

Android :: OutOfMemory Exception Appears While Scrolling The List Of Images

Jan 15, 2010

I have a list of 70 text items with image icons(which are stored in drawables folder).
If I launch application the first time and scroll the list slowly - the exception doesn't occur.

When the application is launched the first time and I scroll the list with 'fling' action the following exception occurs:

COD:.....................

After that, if I kill the application with DDMS, start it again and scroll it with 'fling' action, exception doesn't occur. So the exception arises only if application is installed and launched the first time.

Here is the adapter I use for the list:

CODE:................

Is there a way to avoid the exception? Should I catch the exception and escape the memory somehow?

View 1 Replies View Related

Android :: Loading A Resource To A Mutable Bitmap

Sep 11, 2010

I am loading a bitmap from a resource like so:

Bitmap mBackground = BitmapFactory.decodeResource(res,R.drawable.image);

What I want to do is make some changes to the bitmap before It gets drawn to the main canvas in my draw method (As it would seem wasteful to repeat lots of drawing in my main loop when it isn't going to change). I am making the changes to the bitmap with the following:

Canvas c = new Canvas(mBackground);
c.drawARGB(...); // etc

So naturally I get an exception

java.lang.IllegalStateException: Immutable bitmap passed to Canvas constructor

So to avoid that I made a copy of the bitmap so that it is mutable

Bitmap mBackground = BitmapFactory.decodeResource(res,R.drawable.image).copy(Bitmap.Config.ARGB_8888, true);

Which avoid the problem however it sometimes causes OutOfMemoryExceptions, do know any better ways of achieving what I want?

View 2 Replies View Related

Android :: Optimizing Bitmap Loading By Using ASyncTask

Aug 4, 2010

I have been trying to optimize my single thread app which loads a bunch of tiles that makeup a large bitmap.The app was becoming very sluggish when it would load the new tiles into system memory.I'm now looking trying to use Async Tasks for this purpose. The app detects which tile is in the top left in a method called by onDraw, creates a string that contains the path of the bitmap in the Assets folder, and then checks to see if the bitmap is null before drawing. If it is null, it will load it into memory. My idea was to process the bitmap in DoBackground, and in postExecute trigger a view invalidate to display the async loaded bitmap. Few questions:

1.) can i execute my aSync task for each bitmap? (this statement: new myAsyncTaskManager().execute(bitmapPath); if not, what is the best way to go about it since the only thing aSync will do is just load bitmaps into memory?

2.) Is it possible to set the priority aSyncTask if the bitmaps load too slow?

3.) Is there a better way to go about this? im certain it is the bitmap loading, and not the canvas drawing that slows down the app.

My temporary aSync code:

private class myAsyncTaskManager extends AsyncTask<String, Void, String> {

@Override
protected String doInBackground(String... bitmapPath) {
Log.e("sys","i ran using aTask");
try {

bitmapArray[rectBeingDrawn] = BitmapFactory.decodeStream(assetManager.open(imagePathToLoad));

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} return null;
}

@Override
protected void onPostExecute(String result) {
// execution of result of Long time consuming operation
mCampusMap.invalidate()

View 2 Replies View Related

Android :: Loading An Alpha Mask Bitmap

Oct 28, 2010

I have a single-channel PNG file I'd like to use as an alpha mask for Porter-Duff drawing operations.If I load it without any options, the resulting Bitmap has an RGB_565 config, i.e. treated as grayscale.If I set the preferred config to ALPHA_8, it loads it as a grayscale ARGB_8888 instead.How can I convince Android to treat this file as an alpha mask instead of a grayscale image?

mask1 = BitmapFactory.decodeStream(pngStream);
// mask1.getConfig() is now RGB_565

BitmapFactory.Options maskOpts = new BitmapFactory.Options();
maskOpts.inPreferredConfig = Bitmap.Config.ALPHA_8;
mask2 = BitmapFactory.decodeStream(pngStream, null, maskOpts);
// mask2.getConfig() is now ARGB_8888 (the alpha channel is fully opaque)

View 1 Replies View Related

Android :: Temp Storage For Bitmap

Oct 13, 2009

My program creates a bitmap and successfully stores it on external storage (Images.Media.EXTERNAL_CONTENT_URI).

The next option to implement is to share the image. I'm thinking about different way of doing it: 1. Save it as captured image (as before) and startActivity with Intent.ACTION_SEND intent with the saved image uri. 2. Save it in application's home directory (getFileStreamPath()), startActivityForResult as in 1. and I hope that I'll recieve a result when the message is sent. 3. Save it in some kind of temp/cache folder and don't bother about deleting it or delete it as in 2.

Personally I prefer the second option.

My questions are: Will it work with startActivityForResult() as in 2. ? Do I have access to temp/cache folder as in 3. ? If I do, Should I delete the file afterwards ? May be some flag for Intent.ACTION_SEND to delete the file afterwards ?

View 6 Replies View Related

Android :: External USB Storage

Apr 30, 2010

Is there a way to access an external mass storage device from the USB port of an Android phone? I have a project I'm working on, but I'm stuck on that part.The goal is to plug my DSLR into the phone's USB (I made a specific cable to do just that) and access the pictures from the phone, then with my phone running an FTP server app broadcasting over WiFi, access the pictures on my camera from my computer.I'm stuck on accessing the files on my camera from Android. Is this even possible?

View 8 Replies View Related

Android :: Loading External Data On Local File In WebView

May 27, 2009

when I load external web page, image or javascript file from local webpage. I can't see external image and can't load javascript or webpage. But I can only see local image. Why I can't load external javascript, webpage or image? Here is the HTML source. (of course, I filled right [daum open API key])

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta
http-equiv ="Content-Type" content="text/html;
charset=UTF-8"> <title>Daum 지도 API</title>
<script type="text/javascript"
src="http://apis.daum.net/maps/maps.js?
apikey=[daum open API key]" charset="utf-8"></script> </head> <body>
<div id="map" style="width:600px;
height:400px;
" style="border:1px solid #000">
</div> <img src="http://4.bp.blogspot.com/_2-7AdSkZA7I/RlCnDhD3ZfI/ AAAAAAAAE9U/LEHMtyVLdY8/s400/CutyTale10.jpg">
<img src="file:///android_asset/coffeebean.jpg">
<script type="text/javascript">
var map = new DMap("map", {point:new DLatLng(37.48879895934866, 127.03130020103005), level:2} );
</script> <iframe src="http://www.daum.com" width="300" height="150"></iframe> </body> </html>

and I use this Activity source
package bo.my.android.test;
import android.app.Activity;
import android.os.Bundle; import android.webkit.WebView;
public class OpenAPITest extends Activity {
WebView webView;
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView) findViewById(R.id.webView1);
webView.setWebViewClient(new DaumMapClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("file:///android_asset/daummap.html");
//webView.loadUrl("http://www.daum.net");
} }

View 3 Replies View Related

Android 2.2 Phone - Dynamically Loading External Library At Runtime?

Jul 29, 2013

I am using and android 2.2 phone for testing and getting an error.

07-27 01:24:55.692: W/System.err(14319): java.lang.ClassNotFoundException: com.shoaib.AndroidCCL.MyClass in loader dalvik.system.DexClassLoader@43abbc20

First I wrote the following class:

Code:
package org.shoaib.androidccl;
import android.util.Log;
public class MyClass {
public MyClass() {
Log.d(MyClass.class.getName(), "MyClass: constructor called.");
}
public void doSomething() {
Log.d(MyClass.class.getName(), "MyClass: doSomething() called.");
}
}

And I packaged it in a DEX file that I saved on my device's SD card as `/sdcard/testdex.jar`.

Then I wrote the program below, after having removed `MyClass` from my Eclipse project and cleaned it:

Code:

public class Main extends Activity {
[MENTION=1299008]supp[/MENTION]ressWarnings("unchecked")
[MENTION=439709]override[/MENTION]
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

[code]....

View 2 Replies View Related

Android :: Accessing External USB Storage

Jun 4, 2010

Are there Android API's to access data from an external USB device, such as a hard drive? I need to write an app to interface with an external usb device, is this possible? What system calls are used?

View 2 Replies View Related

Android :: Internal Memory And External Storage

Aug 18, 2010

I've started seeing some apps that offer to read/write data to the internal phone memory (like Super KO Boxing 2, which offers to save a whopping 52MB to the phone memory). I suppose this is because newer Android devices have a lot of internal storage, as opposed to my devices, which have very little. I would like to support internal storage in my app as well.

But it's a bit difficult to implement a solution to something that I don't really know how it works. For example, do these newer devices allow users to upload files to the internal memory, like it's possible to do with the SD card? Can someone explain internal storage from an user perspective and recommend strategies for supporting read/write operations both for internal and external memory (ie: letting the user choose which memory to use at startup, like the Super KO Boxing 2 app)?

View 1 Replies View Related

Android :: Application Data - Internal Or External Storage

Oct 3, 2010

I have a question about where people expect me to store my application data. I have an application where the user will enter information via the keypad, and download information (including images) from a website. Where is the proper place to save this? Internal or External Storage?

View 5 Replies View Related

Android :: Directories And Files On External Storage Are Invisible

Oct 11, 2010

I have created a directory and even a file in that directory on the external storage, I am able to read and write into that but the problem is they are not visible on the emulator i.e, in the phone.

View 17 Replies View Related

Android :: Internal And External Storage - Force Close

Jul 6, 2010

I have an app that accesses music and I had at least one user complain that some of his songs are on internal storage and that causes a force close. My question is do I have to do 2 calls for each song now or can I make a query that will look at both the internal and external memory?

View 1 Replies View Related

Android :: Activity Get Notified When External Storage State Changes?

Jul 24, 2010

I would like my Activity to be informed when the SD card is removed, since it relies on files from the SD card (to keep apk size down) but for compatibility reasons is not targeted at Froyo. I'd like to close the application when the SD card is removed/mounted (giving the user a dialog message to inform them of course) so that I don't get IOExceptions etc (I'd quite like to not have to check everytime I load a file to see if the external storage is available, I already do a check on application launch). There doesn't seem to be any attribute in the manifest for this (like configChanges) that I can find.

View 5 Replies View Related

Android :: Check Availability Of Space On External Storage

Jul 2, 2010

How do you check if the SD card is full or not so that your application can decide if it can continue to do its job i.e. write to external storage or notify the user that storage has run out of space.

View 3 Replies View Related

Android :: Way To Delete App Associated Files From External Storage On Uninstall

Jan 1, 2010

It'd be convenient if an application I'm writing stored some files to external storage permanently (so they persist after the application has been exited[destroyed]), but on an uninstall I'd like to do the decent thing and have these files removed to free up the storage.

Is there any way I can have these files removed on an uninstall?

If there isn't (and I'm skeptical), then I'll have to create these files each time. I'm trying to save start-up time and also occupy required space by having them exist permanently.

Note: I need to use external storage, so both internal storage or a DB would be inappropriate.

View 1 Replies View Related

General :: CM 10.1 - No External Storage Available?

Jun 25, 2013

I flashed CM 10.1 Final Release on my Sprint GS3 and whenever I try to use the camera or gallery, I get a message saying "No external storage available." SPH-L710

View 9 Replies View Related

Android : Way To Delete Image File In External Storage After Email Sent?

Sep 20, 2010

I am storing image in External storage using MediaStore,and send email with attach that image,image saved and sent email with attachment is working fine,i want to delete that image in external storage after mail sent.anybody knows,please give sample code for me..

View 1 Replies View Related

General :: USB Storage - External SD Card Not Seen In PC

Mar 9, 2014

Recently I started using 32GB card with my Micromax Canvas HD and everything is working only for when I try to connect my mobile to PC for file transfer via usb storage I can see only two drive one of CD drive of mmx and other internal sd drive and I can see one more drive but it is not mounted which is my external sd drive when clicked on it, it asked to enter disk.

Solution tried so far by me
1. I have erase external sd card in mobile itself.
2. Reset the entire phone.
3. Uninstalled the mmx driver on my PC and reinstalled it.

View 1 Replies View Related

General :: How To Make Default Storage As External SD Card In Android Tablet

Oct 2, 2013

I have purchased iball slide 3G 7271 ( 3G model ) (Android version 4.0.4) in India. Available Interneal SD memory 2GB.I have external micro SD card slot expandable upto 32GB.

I have downloaded and installed many games in it...but now whenever I try to download new ones , it says "INSUFFICIENT SD MEMORY"

In order to use my external SD card for installing the games and other things....

I have gone through Google search and found ""FolderMount "" software and downloaded to my tab.

I have installed also. It was successful.when I open FolderMount, it says......""serching for root "" ( with one EXIT button to cancel)....and doing nothing beyond that.

View 5 Replies View Related

Android :: Access Programatically Internal - Flash And External - Sd Card - Storage Values

Oct 18, 2010

Does anyone know how to access programatically the internal(flash) and external(sd card) storage values such as space used and space available? I cant seem to find an api anywhere?

View 4 Replies View Related

General :: Google MUST Support External Storage

Oct 9, 2012

None of the Google Applications support external storage, Gmail 4.1.2 won't send documents attached from an external sd card, Play Movies & TV won't allow you to specify a external card as a storage location, pinned Google Drive documents can't be stored on an external card, Play Music sucks up internal memory. Try sending an attachment using Gmail from a Motorola Xoom, a "Google Experience Device".

How do we get Google to support this? Most other email applications support it, but as a Google Apps Enterprise user I want and expect the native Android email application to work.I use external storage on a Galaxy Note 10.1, Galaxy S3, Razr Maxx and Transformer Prime.

View 1 Replies View Related

General :: Swap Internal And External Storage ICS?

Oct 15, 2013

So I have this GT n7000 with android 4.0.4 ICS, rooted. I want to swap my 32 gb external sd card with my internal one. I googled it, found a method that included replacing a vold.fstab file in system/etc but that was only for jellybean. I need a method for ICS. Also I can't understand what usb storage means. Is it different form internal sd card??

View 5 Replies View Related

Android :: Loading Only Part Of Bitmap File In Android

Mar 30, 2010

I would like to load a cropped version of a bitmap image into a Bitmap object, without loading the original bitmap as well. Is this at all possible without writing custom loading routines to handle the raw data?

View 1 Replies View Related

General :: How To Install App On External SD Card And Not On Internal Storage

May 7, 2013

How can I install app on external sd card and not on internal storage.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved