Android : Keeping A Bitmap In Memory With Retain Non Configuration Instance()

Jul 24, 2010

I have a large bitmap that i would like to keep in memory when the qwerty keyboard is visible. My app is always in landscape, so this is the only configuration change that will cause a reDraw. I heard this is what onRetainNonConfigurationinstance() is for...but cant figure it out. Can someone point me in the right direction?

Android : Keeping a bitmap in memory with Retain Non Configuration Instance()


Android :: Keeping Service Alive Across Configuration Changes

Apr 7, 2010

The default way configuration changes (i.e., rotates) are handled is to destroy the activity & recreate it with a new one. What is the recommended way to handle these changes in an activity that binds / unbinds to a service (that is possibly heavy/slow to start)? When the activity gets destroyed, it unbinds & causes the service to be destroyed. When the new activity is created, it binds & recreates the service.

The only choices seem to be:
-- override onConfigurationChanged in the activity. Feels ok, but non - conformant.
-- explicitly start the service & only stop it when the last activity gets an onDestroy that's not due to a config change (i.e., there was no call to onRetainNonConfigurationInstance). Feels icky.
-- explicitly start the service & don't stop it until some amount of time after the last unbind. Ickier.

On a related note, what happens between activity switches within a process, where the first activity (A) starts the next activity (B) & then calls finish() -- is there a guarantee that B.onCreate is called before A.onDestroy? If not, and the activities share a service, the same issue of keeping the service alive during this window exists, but with only the icky workarounds.

View 7 Replies View Related

Android :: Instance-specific AppWidget Configuration

Sep 3, 2010

Say that there is an App Widget that shows a configuration Activity when placed. The configuration page allows adjusting the appearance of the widget.

The user may place multiple instances of this widget on their home screen. What would be the best way to maintain the unique configuration states on each of the widget instances? Or would each widget instance have to adopt the same global state?

View 1 Replies View Related

Android : MediaPlayer Instance Seems To Crash My Emulator During Configuration

Apr 25, 2010

I'm and android beginner, so go easy on me. I'm trying to play a sequence of video files which I'm downloading from a server. The challenge is that I want to have a smooth transition from one file to another.

My thought is to have two MediaPlayer instances each preparing and then playing in turn. It is not clear to me if they can both share the same SurfaceView?
Or maybe, I should be using different views and swapping between them? Or, the idea is a bad idea all together?

When I try to run configure the MediaPlayer instance with a view that isn't visible it seems to crash my emulator.

View 1 Replies View Related

Android : Crop Bitmap Without Reading Entire Bitmap / Cannot Read Image Into Memory

Jul 21, 2010

I have a very large image and I only want to display a section the size of the display (no scaling), and the section should just be the center of the image. Because the image is very large I cannot read the entire image into memory and then crop it. This is what I have so far but it will give OutOfMemory for large images. Also I don't think inSampleSize applies because I want to crop the image, not lower the resolution.

Uri data = getIntent().getData();
Input Stream is = getContentResolver().openInputStream(data);
Bitmap bitmap = BitmapFactory.decodeStream(is, null, null);

Any help would be great?

View 3 Replies View Related

Android :: How To Save A Bitmap Instance To A Bmp File?

Jun 27, 2009

How can i save a Bitmap instance to a *.bmp file?Anyone knows? Is it strange that we can only save a bitmap instance to a png or jpg file?

View 7 Replies View Related

General :: Find Bluetooth Speaker That Can Retain In Its Memory Multiple Devices

Feb 22, 2012

I am trying to find a Bluetooth speaker that can retain in its memory multiple devices (5 preferred but 3-5 is okay too). I know the Bose Soundlink does this, but it is more money than I want to spend right now. I have an imonster, but it only remembers one device at a time.

View 3 Replies View Related

Android :: Smartphone Memory Configuration - Inbuilt ROM And RAM

Jul 17, 2010

Smart-phones have built in ROM and RAM separately. Also a few phones has virtual memory support too. I would like to know what these memories are basically used for. I understand that RAM is available to user processes. But why do they have a big chunk of ROM? E.g. The wiki page for Droid Incredible says

512 MB DDR RAM
1 GB ROM (748 MB free to user) - what's this free to user?
plus 8 GB moviNAND - typically used for data storage

View 1 Replies View Related

Android :: Keeping Data In Memory And Database At Same Time

Sep 9, 2010

We're designing an Android app that has a lot of data ("customers", "products", "orders"...), and we don't want to query sqlite every time we need some record. We wanna avoid to query database as most as we can, so we decided to keep certain data allways in memory.

Our initial idea is to create 2 simple classes:

"MemoryRecord": a class that will contain basically an array of objects (string/int/double/datetime/etc...), that are the data from a table record, and all methods to get those data in/out from this array.
"MemoryTable": a class that will contain basically a Map of [Key,MemoryRecord] and all methods to manipulate this Map and insert/update/delete record into/from database.

Those classes will be derived to every kind of table we have in database. Of course that there are other usefull methods not listed above, but they are not important at this point.

So, when starting app, we will load those tables from SQLite database to memory using those classes, and every time we need to change some data, we will change in memory and post it into database right after.

But, we want some help/advice from you. Can you suggest something more simple or efficient to implement such thing? Or maybe some existing classes that already do it for us?

Update:

I understand what you guys are trying to show me, and I thank you for that.

But, let's say we have a table with 2000 records, and I will to list those records. For each one, I have to query other 30 tables (some of them with 1000 records, others with 10 records) to add additional info in the list, and this while it's "flying" (and as you know , we must be very fast at this momment).

Now you'll gonna say: "just build your main query with all those 'joins', and bring all you need in one step. SQLite can be very fast, if your database is well designed, etc...".

OK, but this query will become very complicated and sure, even SQLite be very fast, it will be "too" slow (2 a 4 seconds, as I confirmed, and this isn't a acceptable time for us).

Another complicator is that, depending of user interaction, we need to "re-query" all records, because the tables involved are not the same, and we have to "re-join" with another set of tables.

So, an alternative is bring only the main records (this will never change, no matter what user does or wants) with no join (this is very fast!) and query the others tables every time we want some data. Note that on the table with 10 records only, we will fetch the same records many and many times. In this case, it is a wast of time, because no matter fast sqlite be, it will allways be more expensive to query/cursor/fetch/etc... than just grab the record from a kind of "memory cache". I want to make clear that we don't plan to keep all data in memory allways, just some tables we query very offten.

View 2 Replies View Related

Android :: AppWidgets - Reusing RemoteViews Instance Leaks Memory?

May 21, 2009

I'm writing a widget. Currently, I'm have a simple ImageView, and calling RemoteViews.setImageViewBitmap(). I'm using a service to do the updates.

I thought it might be a good idea to reuse an existing RemoteViews instance, so I'm only querying it the first time around, and subsequently simply call setImageViewBitmap() with the new image.

This works well initially, but after some time I first start getting "!!! FAILED BINDER TRANSACTION !!!" errors, and later, an OutOfMemory exception.

Simply creating a new RemoveViews instance every time works flawlessy on the other hand. I'm just curios why that would be, any ideas?

View 2 Replies View Related

General :: Lock Apps In Memory Without Keeping Icon In Status Bar?

Nov 21, 2013

Any way to lock apps in memory without keeping icon in status bar? I guess I have problem with Lux auto brightness and Keep Screen On. I turned off icon of this apps in bar, and they are stopping working I guess that is because android JB is killing them when there is no icon.

View 6 Replies View Related

Android : Anyway To Pre Allocate Memory For A Bitmap?

Sep 27, 2010

Is there any way to pre allocate the memory required for a bitmap. Android's memory model is making it very difficult for me to cache images I need to cache.

It would seem the problem is because the VM heap rarely shrinks itself, so I would like to just allocate memory for bitmaps ahead of time? but I can not figure out how to do this?

View 4 Replies View Related

Android : Looking At Heap Bitmap Memory Per Session?

Feb 26, 2009

Ok I am at the end of my rope. I am doing some image processing. I have a large image file which I open and create a smaller bitmap from. At the end of processing I call recycle on everything. I null everything. I run GC manually.

I then try edit another image and I get an out of VM memory error. Bitmap exceeds etc etc.

I am looking at the heap and the secone edit doesn't seem to cause it to increase at all.

What else can I do. Surely google cannot possibly be suggesting that we can open one large bitmap per session and thats it?

View 16 Replies View Related

Android : How To Guestimate Available Bitmap Memory On A Device

May 13, 2009

Part of my application allows the user to color-correct images. When i open an image for editing, i'd like to know what, more or less, the available bitmap memory is for the device that the app is running on.

For the G1, the limit is use is about 6MByte (about a full-size image that can be taken by the phone (3MPixels) with 16 bit color ==> 6MByte). If i try to open anything larger, i often get an out-of- memory exception. Limiting it to 6MByte reduces these OOM exceptions by a great deal. However, i can see future devices having more memory available because (as one of the reasons) they can take larger pics (e.g. 5MPixel or something).

Right now, my app just uses a hard-coded limit of 6*1024*1024. Is there a way to make this variable, to future-proof this by examine the device my app is running on. If so, how?

View 10 Replies View Related

Android :: Out Of Memory On Bitmap But There Is Free Heap Space

Aug 10, 2010

I have a list view that display about 25 images with size 60x60 pixels. I dowload this images from internet and I store in an arraylist as Bitmap. I need to save it in a arraylist because a listview will recycle views and so I need, wenn the user scroll, to display the image in the new view WITHOUT downloading again from internet

But after some time I got

java.lang.OutOfMemoryError: bitmap size exceeds VM budget

It seams that I got this exception about after loading 20 images ...

Reading in forum I have read about memory heap.

I try to check the memory heap usage with: Debug.getNativeHeapAllocatedSize and Debug.getNativeHeapSize()

When the exception occours both are about 4M.

But android has more than 4M?

When the application start the values are a little less to 4M so it seams is not a big memory usage or memory leak.

To be sure I want to call : ActivityManager.getMemoryClass() but this method is and instance method and I can't find the object to invoke!

But this method say, that al min should an application have 16M!

Any help? I have seen many topics in google ... but all speak about recycle. But if I recycle a bitmat ... then should I download again from internet?

Should I store the image on flash memory or sd card instead an arraylist in memory?

View 6 Replies View Related

Android : Profiling Bitmap Memory Usage To Optimize?

Jan 15, 2010

My game - Tower Raiders - is continually floating fairly close to running out of bitmap memory. Unfortunately, I haven't found good information on profiling bitmap memory usage so that I can optimize / make informed decisions / add new content if it allows / etc.

I'm aware that bitmap memory is not heap memory, as it's allocated natively. But that it is accounted for somehow in the VM and influences garbage collection. Maybe it's an oversimplification of how bitmap memory works - but I'd like to find a tool etc or some way of determining I as the game is running right now, there are no more than X bytes of usable bitmap memory remaining.

So, if anyone has any advice etc that would help me in these respects I would greatly like to hear about a workflow for this.

View 2 Replies View Related

Android : Bitmap Memory Handling With ImageView.setimage

Jun 4, 2010

I've read a lot of previous messages on this topic but couldn't find universal agreement on the whole. I can't reproduce this in house, but a customer got an OutOfMemoryError when using an icon chooser dialog.

This dialog is much like the Grid1 example - only it's in a dialog.

The bitmap memory seems to run out after running the dialog a few times for a customer, resulting in java.lang.OutOfMemoryError: bitmap size exceeds VM budget. Should I try to call recycle on the bitmap from an ImageView when I reuse the view? Or would the ImageView do that anyway?

But even if I do that, that's only a small portion of the bitmaps because most of them are seen without scrolling. The Adapter and the GridView are both local variables and therefore shouldn't be referenced after the dialog is dismissed.

I do believe that it should be possible to use many bitmaps in an app - Google Maps does it, Picture Gallery does it. But maybe I need to learn more rules. Some say you should call bitmap.recycle, some say you shouldn't have to. Many say calling gc.collect will make it worse, etc.

View 2 Replies View Related

Android : Internal Implementation Of Bitmap Class Use Shared Memory?

May 26, 2009

When I pass a Bitmap using the Binder Remote service mechanism, does the internal implementation of writeToParcel/createFromParcel of the Bitmap class use shared memory?

View 5 Replies View Related

Android : Out Of MemoryError With Bitmap / Working With Large Images With No Memory

Jul 22, 2010

I'm developing an image editor for Android. When I do some operations with small pictures (600x600 - 1024x768), the program work well. But when I do some operations with big pictures, I always obtain an OutOfMemory Error. I read read many post trying to have the image in memory. Also I looked at the Android's Gallery, trying to simulate the effect of loading the image with lower quality and get the complete quality after a while. But I doesn't get to work with large images.

I thought of using the parameter inSampleSize but I raised the problem of having to perform operations on the image and save it with the original size, so it no longer serves me. The only thing I've done is use the parameter inJustDecodeBounds and display an error to the user if the image exceeds the available memory.

Is there any possibility of working with large images with no memory problems? I need urgent help.

View 19 Replies View Related

Android :: Total Memory Doesn't Grow To Make Room For Bitmap?

Dec 23, 2009

I've been doing a lot of searching and I know a lot of other people are experiencing the same OOM memory problems with BitmapFactory. My app only shows a total memory available of 4MB using Runtime. getRuntime ().totalMemory(). If the limit is 16MB, then why doesn't the total memory grow to make room for the bitmap? Instead it throws an error.............

View 1 Replies View Related

Android : Is Decreasing Size Of .png Files Have Some Effect To Resulted Bitmap In Memory

Apr 8, 2010

I'm writing game with a large amount of .png pictures. All worked fine. Than I added new activity with WebView and got memory shortage. After that I made some experiment - replace game .png images with ones that just fully filled with some color. As result memory shortage had gone.

But I suppose that Bitmap internally hold each pixel separately so such changes should have no effect. Maybe this because of initial images have alpha channel and my test images have not it?

But actually question is: Will decreasing .png images files sizes make some effect on decreasing usage of VM application heap or not?

View 3 Replies View Related

Android : Java.lang.out Of Memory Error - Bitmap Size Exceeds VM Budget

Aug 19, 2010

In my application am displaying a list of names and respective pictures ? I am picking picture from gallery through Durable.getFromPath(). ? am displaying list , some i encountered with out of memory error ? please help me to sort out this error?

View 1 Replies View Related

Android :: Android Out Of Memory Error / Bitmap Size Exceeds VM Budget

Jul 24, 2010

I am facing a problem of Out Of Memory Error that is bitmap size exceeds vm budget while changing the orientation of the Droid mobile (but not in any of other mobiles like Android normal and Android small).I am displaying 10 images in grid view, each one size is less than 20kb. If i insert 6 images then it doesn't arise that error.

View 1 Replies View Related

Android : Android Custom View Bitmap Memory Leak

Nov 16, 2010

I've got a custom view in which I need to draw two bitmaps, one is a background, representing the image of a map and one is a pin which will be drawn on top/left position in canvas.

The both images are drawn onDraw and remain the same during the live of the activity that contains the view. After a while I get a OutOfMemoryError: bitmap size exceeds
VM budget

This means that I have a leak and the bitmaps don't get garbage collected. I asked this question before, but now the situation changed a little. I made a init method where I set the bitmaps I want to use but this still isn't a good approach, the error appears later, but still there.

Here is the code:

public class MyMapView extends View
private int xPos = 0;
private int yPos = 0;
private int space = 0;

private Bitmap resizedBitmap;
private Bitmap position;
private Bitmap mapBitmap;
public void destroy()

resizedBitmap.recycle();
resizedBitmap=null;
position.recycle();
position=null;
mapBitmap.recycle();
mapBitmap=null;

I call the setMapBitmap() and init() on onCreate of the activity that contains the view. In there I know what bitmap will be used as map. onPause of the activity I call the destroy() of the view. I still get errors.
I've read this this but I don't know how to adapt it on my case

I AM OPEN TO ANY OTHER SOLUTION. Please note that I need to resize the map bitmap (based on the height of the layout that contains it in mai activity) and still be able to draw the position on correct place.

View 1 Replies View Related

Android :: Create Mutable Bitmap From Camera - Draw Another Bitmap On Top - And Save It

Apr 2, 2009

I am 1) taking a picture and 2) then draw another Bitmap on top of it 3) then I store it

I am doing it as follows and it works on the emulator.

On the device I get a OutOfMemoryError: bitmap size exceeds VM budget android.graphics.Bitmap.nativeCopy(Native Method) android.graphics.Bitmap.copy(Bitmap.java:199) in the line copy the Bitmap to get a mutable Bitmap.

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

What I am asking:

a) Is there a better way to do what I am doing? 1) take a picture 2) draw another Bitmap on top of it 3) then I store it

b) What is the best way to create a mutable Bitmap from the picture I just took with the camera?

In my app, resolution is not an issue. If it works better for small photos that would be fine.

View 3 Replies View Related

Android :: How To Retain EditText Data When Back Key Pressed?

Sep 1, 2009

I have a EditText filed in my Activity class, Where I need to retain data, when orientation is changed or "HOME" button is pressed or "BACK(FINISH)" is pressed. Android internally maintaining EditText when orientation is changed or HOME button is pressed. But it is not maintaining EditText status when BACK button is pressed. How can I make it happen to retain data in all three cases (orientation is changed, HOME is pressed, Back is pressed) in a feasible way?

View 9 Replies View Related

Android :: Retain Application / Activity State Correct Approach?

Dec 22, 2009

I just read from internet to maintain the state of my application by overriding the onKeyDown function as given below. And set the launch mode of my activity as singleInstance. And it is working perfectly. Just want to know if it is correct approach. And how it is different from onSaveInstanceState.

View 3 Replies View Related

Android :: Overlay Bitmap - Draw Over A Bitmap

Oct 8, 2009

I have two questions actually:

Is it better to draw an image on a bitmap or create a bitmap as resource and then draw it over a bitmap? Performance wise... which one is better?

If I want to draw something transparent over a bitmap, how would I go about doing it?

If I want to overlay one transparent bitmap over another, how would I do it?

View 1 Replies View Related

Android :: Draw A Bitmap Rotated Onto Another Bitmap

Mar 22, 2009

My goal is the draw a bitmap onto another bitmap but rotated 90 degress. whats the most efficient way to do that. My current method is as follows which is horribly bad because it creates a new bitmap every time.

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

View 4 Replies View Related

HTC Desire :: Way To Retain Usage Of Phone's Contact Picture?

May 10, 2010

How do I retain the usage of phone's contact picture instead of Facebook sync's pics? I just sync'ed and some of my contacts (that are also on Facebook) still used the original picture from my phone while some used FB's profile picture. is there an option that if the contact has picture already on the phone, then don't use FB's profile picture?

View 1 Replies View Related







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