Android :: Rule That Relates OnMeasure To The Activity Lifecycle
Jul 12, 2010
I have a custom view on which I need to call a method from my activity after the view has been measured in onMeasure. I would like to know exactly when onMeasure is called in the View layout process. It looks like onMeasure is called after my activity´s onCreate, onStart, and onResume. I could override onMeasure and maintain a variable that contains whether the view has been measured or not. However it would be nice to know if there is a rule that relates onMeasure to the activity lifecycle?
View 4 Replies
Oct 5, 2010
In the Android Application Fundamentals it says that after the call to the onStart()-method of the activity lifecycle either the callback method Resume() or onStop() is called. In case of an "normal" Start of an activity the system calls onCreate(), onStart(), onResume().But does somebody know an example where onStart() - onStop() are executed one after another?
View 2 Replies
View Related
Jul 14, 2009
I just ran into a situation where it looks like a static variable reference is persisted across activity sessions. I didn't expect that because I thought that when an activity exits, it's de-referenced and garbage collected. I am wondering if anyone can shed some (more) light on when the VM eliminates object references for Activities and Services and in particular when static variables get reset to default values?
View 7 Replies
View Related
Aug 7, 2009
http://developer.android.com/reference/android/app/Activity.html
The Activity Lifecycle could have implementation and or design bug: One case is to initialize a big image in onCreate(), try to reuse the image during the whole lifecycle, and then recycle the image in onDestroy(). Test showed that onCreate() is called every time one navigate away from the activity and back again, but onDestroy() is not called at all. This behavour causes memory leaking for the big image (size 960*1920). After 6+ times away and back to activity, the system runs out of memory and has to kill the process.
One workaround is to initialize the big image in onResume() and recycle in onPause(), but that's not so good reuse.
Could it be better to change the process (as shown in the diagram) a little bit such as: Call onDestroy() first when a process is killed?
View 3 Replies
View Related
Mar 4, 2010
I have a problem with the activity lifecycle specifically on Nexus One (2.1 running on emulator works fine). If I just create a simple empty Activity with no special launchModes that logs the calls on the onStart and onStop methods, this is what I see: - launch app: onStart called; - home button: onStop NOT called; - launch app: onStart NOT called; - home button: onStop NOT called: and so on. Sometimes if I press the back button then the onStop is not called, but the when i launch the activity again the onStart is called and right after the onStop is called. Similar results with different launchModes. What is going on? Can anyone confirm this?
i found an android issue for the problem here: http://code.google.com/p/android/issues/detail?id=6094 and a similar thread here http://groups.google.com/group/android-developers/browse_thread/threa.
View 24 Replies
View Related
Sep 15, 2010
I'm binding to a local Service (that is, not using IPC and AIDL) from several activities. I want to ensure that I'm not holding references to this service from activities that the user isn't using. My options are: 1.) to bind to the service in onCreate() and unbind in onDestroy(). 2.) bind in onStart() and unbind in onStop(). 3.) bind in onResume() and unbind in `onPause(). Or some combination of these. Which is the best-practice way of binding and unbinding to a local service? Do I not need to be concerned with holding local connections from stopped activities? Additionally, once bound to this particular service I am retrieving a Cursor which is attached to my ListActivity via a CursorAdapter. The data retrieved by the Cursor may have changed while the Activity was out of view so I want to requery it when the Activity is shown again. If I bind in onCreate() I can requery in onRestart(). If I bind in onResume() each time the data will be fresh because I'll query it in the Service's connected callback.
View 1 Replies
View Related
Oct 4, 2010
I'm having a couple of problems with an alarm app I am developing.
The first thing that I think is a bit weird is that when an alarm goes of and wakes the phone up. These things happend.
oncreate
onresume
onpause
onresume
Why are they run in that order? The last two should not be called? And this is what's causes me big trouble, because when i press home or back on the phone, onPause is run, which I want to call finish() from. And that part works as it should, but that does not work when the phone wakes upp from sleep bacause of the onPause call...
View 2 Replies
View Related
Aug 3, 2010
I want to get the size of a view that is in my activity but I am not able to get that information in any of the activity lifecycle callbacks (onCreate, onStart, onResume). I'm assuming this is because the views have not been drawn yet. At what point are views drawn and is there a callback I can put my code so I can get the size of the view?
View 2 Replies
View Related
Nov 26, 2009
My app is made of two activities, A and B. I'm considering this sequence of steps: Activity A is started. A launches B [A is paused, B is running]. B launches a map intent [A and B are both paused now]. Now the user is using the maps application and the system decides it needs more memory. Can the system kill only one of my activities for memory, or will it always kill all activities in a "process" in this situation?
Both activities share some static data like:
class Data {
public static String mName;
public void save() {
// write to file: mName;...................
View 1 Replies
View Related
Oct 26, 2012
I'm writing an application for Android and have multiple Activities, there are three to be exact. When a user drills down to the record they would like to view, they can modify it.
The issues is that when I click the back button to move to the previous screen, i'd like to refresh it to reflect the update performed by the end user. I can't figure out how to hook onto the appropriate event and then refresh my data on that view.
View 3 Replies
View Related
Jun 14, 2010
I'm interested in android activity lifecycle and I would like to get more detailed description/documentation/reference than widely available basic (onCreate->onStart->onResume) one.
My need comes from realizing that starting new activity (Theme.Dialog styled) from onAttachedToWindow() greatly improves response time if comparing to starting it from onCreate(). I wonder how this onAttachedToWindow() fits into whole android activity lifecycle. Official API ref description "Called when the window has been attached to the window manager" doesn't help a lot.
View 1 Replies
View Related
Apr 30, 2009
I would like to do some tests on SlidingDrawer however i always found RuntimeException when SlidingDrawer.onMeasure is called i check the code and think the exception is caused by unspecified MeasureSpec
so i would like to ask how to setup the MeasureSpec in SlidingDrawer?
View 2 Replies
View Related
Jul 27, 2010
I have used sliding drawer in my code ...
When i set this as content i am getting RunTime Exception in SlidingDrarwer onMeasure!.
How can i prevent RunTimeException? Where am i doing wrong?
View 7 Replies
View Related
Dec 3, 2009
I have a View that I've placed into a ScrollView.The View paginates text.If the text changes, then the height of this view will also change (expand or contract, depending on whether the new text takes more vertical space or less).For debugging, I draw a rectangle around the view to show its current size. After I repaginate, I cannot get Android to cause the View to change its size -- I have tried calling measure() myself, calling requestLayout(), and calling forceLayout() -- even though my overloaded onMeasure gets called, and calls setMeasuredDimension() with the correct values, the view remains the same size as it was before repagination. What am I missing?
View 2 Replies
View Related
Nov 10, 2008
Meebo, the free IM app is now available for download in the andriod market place.
I've been using www.meebo.com to IM on AIM, MSN, and GTalk with 1 logon and without any download (at work mostly heh) for a while now and I have nothing but praise for it.
Now they're created an app that does the same thing for the G1.
If you'd going to try it out, I'd recommend setting up your accounts on the computer/website first (really easy) that way it's ready to go when you DL the app for the phone.
I'm using it, it works, check it out if you need an all-in-one IM client.
View 20 Replies
View Related
Jun 3, 2010
I read this quote in one of the webpages: If you are writing a large application, consider dividing it into a suite of applications and services. Smaller applications load faster and use fewer resources. Making a suite of applications, content providers, and services makes your code more open to incorporation into other applications as described the "Use and be used" tip. Is this true? What is the thumb rule for the size of app?
View 1 Replies
View Related
Nov 24, 2010
Do any of the current email apps out there now support rules for incoming messages and different alert tones? That's why I'm a slave to my blackberry, I can set certain work emails as priority 1, and assign a different tone to those from certain addresses. If there's an app for Android that does this, I'll pay dearly to be able to have that work. Anyone made such a thing yet?
View 5 Replies
View Related
Apr 20, 2010
I'd like to port my iPhone app to Android. The interface is constructed with artwork designed for 320x480 resolution. What steps do I need to take when I'm constructing the XML interface for the Android so that my GUI will be compatible with the different screen sizes (or at least the most popular ones...)?
View 1 Replies
View Related
Nov 10, 2010
I want to set the background of a Relative or LinearLayout to a custom drawable. I want the shape to draw two horizontal lines across the bottom, leaving the central part transparent (empty). The following draws the horizontal lines centered vertically, where as i need them to be aligned to the bottom of the shape. (If you add a rectangle as an item you can see the shape expands to the dimenstions of the parent, but the lines are still centrally aligned). Code...
View 1 Replies
View Related
Apr 5, 2010
In my application I have several activities, the main screen has 4 buttons that each start a different activity. So one of them is a search activity, once it searches it shows you a result activity. This result activity can be reached from other activities, so in general something like this:
Main activity -> Search activity -> Result activity
Main acitivty -> someother activity -> Result activity
Now, if I have reached this result activity and press back once or twice, and after that press the Home key it will show the Home screen. But if I want to get back to my application by holding the Home button and clicking on my app it will always go back to the Result activity, no matter which activity was the last one I was using. And if I press again back it will take me back to the Home screen.
If I try it again it will take me again to the Result activity. The only way to avoid this is to start the application by clicking on the app's icon. And this takes me to the last activity I was using and it remembers the state so if I press back again it doesn't take me to the Home screen, instead to the activity before it. To illustrate this:
Main activity -> Search activity -> result activity --back--> Search activity --Home Button--> Home Screen --Hold Home and select the app --> Result activity --back--> Home Screen
--Click application icon--> Search activity --back--> Main activity
Another thing that happens is that if I press the Home button while on the Result activity, and start the app by clicking the icon, it will take me to the activity prior the the Result one.
View 2 Replies
View Related
Sep 10, 2010
There's a decent amount of information out there on the Activity lifecycle. But I'm surprised how difficult it is to find a comprehensive description of the rendering lifecycle. By that I mean the order and rules by which a tree of nested activities, views, and drawables get to be sized and drawn to the screen, and the points at which a developer can modify rendering behavior.
View 1 Replies
View Related
Feb 7, 2010
I am having difficulties with the lifecycle of the opengl context. While rendering my scene and the user hits the back button, home button or another application opens in front of my application, my app is still running in the background.
So when my application comes to the foreground later on (user relaunches it or the app that was opened on top of it finishes), my application crashes and leaves me nothing but a GL stack trace which i can't properly decipher.
For rendering i use the GLSurfaceView and therefore delegate the onPause and onResume. The crash happens on the first call to glDrawElements(..).
I have tried to reload my resource (geometry/textures etc.) on onSurfaceChanged but with or without reloading... The problem persists.
This behavior can be observed on all AVD versions of the emulator as well as on the G1.
Here is the gl stacktrace i get.
CODE:.............
View 3 Replies
View Related
Jul 8, 2010
I am trying to create a Servicefor my application which will negotiate Bluetooth connections and data. I want this service's lifecycle to start and end with the Application, but still be able to have specific Activities listen for events that occur within this service (in addition an Activty should be able to call specific methods of the Service to write data or query connection state).
I started by creating AIDL interfaces for my callbacks and service, but I can't figure out exactly what I'm doing.
How is the best way to go about this? EDIT: To be clear, I do not specifically need (or want) more than one process for my application. Right now I don't have more than one; I'm just using AIDL because it is the only way I know of for a Service to communicate with an Activity.
View 1 Replies
View Related
Apr 20, 2010
I have creating application with 3 activities, where A - list of categories, B - list of items, C - single item. Data displayed in B and C is parsed from online XML. But, if I go trough A -> B1 -> C, then back to A and then back to B1 I would like to have it's data cached somewhere so I wouldn't have to request XML again.I'm new to Android and Java programming, I've googled a lot and still can't find (or simply do not have an idea where to look) a way to do what I want.Would storing all received data in main activity A (HashMaps? ContentProviders?) and then passing to B and C (if they get same request that was before) be a good idea?
View 3 Replies
View Related
Apr 19, 2010
I slapped together a simple test application that has a button, and makes a noise when the user clicks on it.
Here are it's method:
CODE:..................
My question is, why is onCreate acting like it's in a while loop? I can click on the button whenever, and it makes the sound. I might think it was just a property of listeners, but the Button object wasn't a member variable. I thought that Android would just go through onCreate onse, and proceed onto the next lifecycle method. Also, I know that my current way of seeing if the sound is playing is crap...I'll get to that later.
View 1 Replies
View Related
Feb 6, 2010
I've an App which performs a potentially large download in background thread. When the orientation changes or the keyboard is opened the App lifecycle system invokes the start/stop/pause/resume etc calls - is there any strategy available to resume the download rather than just set a flag so the new onCreate() knows it was interrupted and has to start it again?
View 2 Replies
View Related
Nov 17, 2010
I'm fairly new in Android/Java programming, so some of the basic stuff is still quite confusing. So, lets say my application gets all data (articles) it requires from external XML files, it parses them to data models (Article class) and those articles will be used (displaying in lists or single article) all over the application for all it's lifecycle.
Where should I keep them? Can I create singleton class with an array containing all the articles I've parsed? Or should I save them to database and then query it on demand? (that sounds like too much work, I don't need to cache them for now) What's the best practice here?
View 2 Replies
View Related
Sep 27, 2009
This is with the 1.6 & 1.5 SDKs, not tried earlier ones. When you switch from portrait to landscape the onSaveInstanceState()/ onRestoreInstanceState() pair are called once, but when going back from landscape to portrait they are called twice, unless I've missed something. To test, see the log after creating a default Hello World app and change the main class like this: code...
View 4 Replies
View Related
May 18, 2010
Does anyone know of any games that are like "We Rule" for the iphone? It involves kingdom building, etc, but doesn't involve "battling" or having to go to war with people (and all the upkeep that entails). I've tried Kingdoms Live and Pocket Empires, but neither is really the same (although Pocket Empires is closer).
View 2 Replies
View Related
Dec 22, 2009
I am creating event search application, we set search criteria from one screen populate in another screen then user can edit search criteria from 3rd screen and goes to 4th screen.To achieve above task i am using static object which remember the values around the application and i don't need to do any thing extra.But i am afraid if about static object life cycle in android if low memory found android delete static objects?As android supports multi tasking, if user switches to another application and when user comes back application start acting crazy, does static object get removed when it multi task?and also suggest holding static object via singleton method is better approach?
View 2 Replies
View Related