Android :: Tell How Close Activity Is To Reaching Its Memory Limit
Oct 15, 2010
I'm writing a graphic design application for Android where the user can add several images to a document, where each image is stored as a Bitmap object. Each bitmap has roughly a dimension of 800x400 pixels and uses ARGB8888 pixel format (i.e. ~1.5Mb each).
I'm aware that most of the first generation Android devices have a 16Mb heap limit and this limit is 24Mb and larger for newer phones. I'm also aware that bitmap memory is allocated externally, but I'm confused and what the implications of this is.
My question is: How can I tell at runtime when adding a new Bitmap will get me too close to the memory limit?
Before someone suggests "don't use that much memory", I know that one option I have is to limit how many Bitmaps the user can create such that I know this limit is safe for the most basic Android phones. However, I'd like for phones with a bigger memory limit to support more bitmaps and/or bigger bitmaps.
I know to check for OutOfMemory exceptions when allocating bitmaps. However, there will be some situations where I've only got just enough memory left to allocate one more bitmap. After this point, the whole application will be unstable because even allocating small things like strings could cause an OutOfMemory exception. This is something I want to avoid.
I'm not sure how to define "too close to the memory limit", but I suspect something like "don't allocate more than half of your available memory to bitmaps" would work OK as my other data structures I store in memory are small in comparison.
View 3 Replies
Nov 1, 2010
Attempted to update to 2.1 , everything appeared to go ok , but after restarting i saw that firmware was still in 1.6 .
The only effect was that my intended apps etc. were gone.
According to SE PC Companion the phone is up to date.
According to the phone's software update a new version of Android is available ..
Using the SE PC Companion to repair ( ca'nt install since aIready have the latest sw according to SE-PCC )
results in installation error when reaching close to the end of the prepare phase.
View 4 Replies
View Related
Jun 30, 2009
07-01 11:32:02.192: VERBOSE/QualcommCameraHardware(35): state transition QCS_WAITING_JPEG --> QCS_IDLE 07-01 11:32:02.232: ERROR/dalvikvm-heap(395): 6291456-byte external allocation too large for this process. 07-01 11:32:02.232: ERROR/(395): VM won't let us allocate 6291456 bytes 07-01 11:32:02.242: DEBUG/AndroidRuntime(395): Shutting down VM 07-01 11:32:02.242: WARN/dalvikvm(395): threadid=3: thread exiting with uncaught exception (group=0x4000fe70) 07-01 11:32:02.242: ERROR/AndroidRuntime(395): Uncaught handler: thread main exiting due to uncaught exception 07-01 11:32:02.302: ERROR/AndroidRuntime(395): java.lang.OutOfMemoryError: bitmap size exceeds VM budget My app shut down when i load a jpg file,i can avoid it by call system.gc().But I think memory limit will be 14M or 16M.
View 24 Replies
View Related
Aug 5, 2010
Is android's memory 16MB limit per Process or Application? If the limit is by process, I can make some services remote. That means the service will be in different processes, and the limit will be 16 x N.
View 3 Replies
View Related
Sep 28, 2009
I created an application which is asynchronously communicating with the server. When the application makes a server request a new dialog (activity) with "loading" notification is created. The main activity implements methods for handling server responses and I would like to close the foreground activity when the main activity receives the answer from the server.
View 1 Replies
View Related
Jul 15, 2010
Is there any way to close the activity the launched another activity? So if activity A starts activity B can activity B close activity A? I know there is the tag android:finishOnTaskLaunch="true" but i only want it to happen if a button is pressed so im looking for a method to do it.
View 10 Replies
View Related
Jun 9, 2010
I have pretty much reached my limit on internal space, but while looks at my apps list on which to delete because I don't use I found only two. I was wondering what will happen if I clear data on the contacts storage i.e. will I loose my contacts, and with the facebook. Is there a way of clearing the data not uninstalling apps if so what data does it clear?
View 5 Replies
View Related
May 10, 2010
Is this possible in an Android app? I want to make it so that no matter how many times a user starts activityA, when they hit the back button they will never get more than one occurence of activityA. What I am finding in my current code is that I have only two options 1. I can call finish() in activityA which will prevent it from being accessible via the back button completely, or 2. I do not call finish(), and then if the user starts activityA (n) times during their usage, there will be (n) instances when hitting the back button. Again, I want to have activityA accessible by hitting the back button, but there is no reason to keep multiple instances of the same activity on the stack. Is there a way to limit the number of instances of an activity in the queue to only 1?
View 2 Replies
View Related
Aug 4, 2009
I have three activity now, a, b and c, a is start point of activity lifecycle, and can go to b or c, and then assume go to b from a and close a, and then go to c from b but will not close b, and this time, I want to check whether b is start(create) or not,
if b start, I want to close b and then go to a, if b doesn't start(possible will go to c from a doesn't via b), it will also go to a but do nothing for b
how can I do for that?
View 5 Replies
View Related
Jun 23, 2009
I have a app,the structure composed three .java, 1.java,2.java,3.java
their relationship is: 1->2->3 and 3 can go back to 1
when i was back to 1 from 3, i want to close the 2, how to do this?
View 13 Replies
View Related
Jul 23, 2009
I have an EditText field and I want to pop up a new window/activity whenever a user touches/clicks the field. The new window has some widgets and of course Apply and Cancel buttons. Here is the code how I intercept the onTouch event.
EditText ctlMaskEt = (EditText)findViewById(R.id.mask_field); ctlMaskEt.setOnTouchListener(new OnTouchListener() { public boolean onTouch (View v, MotionEvent event) { popMaskEditor(); return true; } });
Everythings work fine until I click the Apply and Cancel buttons. The API finish() won't close the new window unless I click the same button one more time. Calling popMaskEditor() from a button's OnClick event handler doesn't have this problem.
View 2 Replies
View Related
Aug 8, 2010
Is it possible to close/finish activities in activity stack from a backgorund service.
View 2 Replies
View Related
Aug 28, 2010
I started to develope an application. When I wanted to close the application I clicked on the home screen, but the app is still playing in the background. Than I tried to click on the "back" key, but nothing happend, so I've created a key event listener for the 'back" key, and inside that method I wrote finish(); Now my app is closing but I think it's still running in the background, because when I go to "manage applications" I can still see it in the "running" tab, and if I press it, I see I can click on the "force close" to actually close the app. What do I need to do in order to really close the app without leaving it open (one way or another)?
View 9 Replies
View Related
Sep 30, 2010
I managed to create a secondary Activity, but now I wonder how I can close it again.
public void button_onClick(View v){
finish();
}
works when I'm dealing with just one Activity at a time, but how do I let the secondary Activity close the entire application?
View 1 Replies
View Related
Nov 22, 2010
Can finish() be used to close an activity from a service? If not, what is the proper way to end an activity from a Service? I've created an activity from my service and need to close it.
View 2 Replies
View Related
Jul 15, 2010
Just got the new Droid X. Coming from a windows mobile phone (which I hated) I have a question on the android OS. It seems that when you are done with an app you just have to hit the menu button again.. but this leaves it in memory running.. is there anyway to close the and and just leave it? I did download the Advanced app killer but that seems silly to have to pick from a list of what you want closed.. I see no way to just close the app you are in.. it should be a default option for every app.. I hope I am just not finding it.. and it is there somewhere..
View 7 Replies
View Related
Jun 29, 2010
My app keeps force closing before it starts, eclipse returns no errors in my code and my xml is good.
package com.mhe.test.scan;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class main extends Activity {
/** Called when the activity is first created. */
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button myScanButton = (Button) findViewById(R.id.myScanButton); myScanButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);
} } );
} EditText totalbox = (EditText) findViewById(R.id.totalbox);
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) { if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
// Handle successful scan totalbox.setText(contents)
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel totalbox.setText("@string/bummer");
} } } }
Essentially it is supposed to call zxing Barcode Scanner to scan a barcode on a button click and return the result into an EditText field.
View 2 Replies
View Related
Sep 10, 2009
Just wondering is it necessary to close cursor when an activity is stopped or pause?
View 5 Replies
View Related
Aug 26, 2010
I want to clear variable value when will i close activity.
View 1 Replies
View Related
Jan 17, 2014
I want to set an email writing down the adress to be send , subject and email body but dont send it right away.Also i will set a location and when i reached that location (through gps) my phone will notice i am there and send the email i set.How can i manage this?
View 1 Replies
View Related
Jul 2, 2009
Is there any way for an activity to register for being notified if a wait/force close dialog is shown or alternatively if the user selects force close, a way to detect that in ondestroy()?
View 6 Replies
View Related
Sep 21, 2009
So I read through the SDK docs and I thought that calling a new activity(browser) as part of a task (myTask) will mean that activity* (browser) will close when a user closes the task (myTask) But I am left with a browser window.
Here is my scenario (in sudo code);
CODE:..........
Question 1: What is the cleanest way to ensure that when a user closes my app, any outside activities called will be closed to.
Question 2: Does a callback URl start a new Task, or use one in the stack if available?
View 3 Replies
View Related
Oct 10, 2009
How can I create a Slide-Bottom-To-Top animation when close/stop an activity in android application?
View 1 Replies
View Related
Feb 19, 2010
I understand that trying to capture home button clicks is a hack, but I need to atleast close my current activity when the user clicks on home button. Is there anyway I can tell the system to close this activity is the user clicks on home button? If so how can I do that? I need to do it as I am listening for location updates and I want to stop the updates and also need to trash any location that was available to me previously. I need to do this just in case any user while in that activity clicks on home button and changes the location settings.
View 7 Replies
View Related
Jul 28, 2009
I have fixed the activity screen orientation to portrait on AndroidManifest.xml file. When I open or close the keyboard the activity gets restarted. How to avoid this restart?
View 4 Replies
View Related
Mar 22, 2010
I'm looking to find out how to stop an activity instead of resuming upon the click of the item on the notification list. Any ideas?
View 1 Replies
View Related
Oct 13, 2010
I have a toolbar view set for most of my activities.
The toolbar has several buttons which all trigger certain intents. Now, the problem is: how can I close current activity before starting another one ?
Problem 1) Activity cones For instance one of the buttons ('A') starts activity A. Activity A also has toolbar. If you press on the 'A' button, a new A activity will be started. I suppose I can look at Activity.getInstanceCount(), right ?
Problem 2) Unnecessary activities The activity X is not needed any more if the opts for A. I just want A then. How can I remove X from toolbar which only has access to context ?
I, of course could find toolbar view inside activity X and override the onClicks, but in general this would mean doing so for all my activities !? Am I on the right track ?
View 2 Replies
View Related
Dec 1, 2013
Not for security, just to stop mobile data internet from reaching some apps. I need to set it by multiple configuration too.
View 1 Replies
View Related
May 21, 2010
I have an Android game that has an activity for the menu, and then another activity for the game that creates a SurfaceView and Thread to deal with canvas drawing and game logic. When you exit the game and start it up again too much or if you open and close the keyboard (thus restarting the activity), the game runs out of memory, usually when loading a bitmap: java.lang.OutOfMemoryError: bitmap size exceeds VM budget keeping all my images in memory without loading them again.
View 3 Replies
View Related
Oct 4, 2010
Is there a way to notify an activity/service of a force-close request right before it gets killed?
I mean when the user hits the force close button in Menu>Settings>Applications>Manage applications>app name>Force Close.
View 2 Replies
View Related