Android :: Lifecycle Of Activities ?
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
Jun 30, 2010
how to call BarCodeScanner, and return the value to a field.so now, i have a toast that says "successful scan" and then i want to pass the result to a new activity. when i comment out my intent, everything works (minus the passing of data/switching of screen, obviously) but when i run my project as is, it FC's no errors reported by eclipse in code or xml. any insights?
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
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
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 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
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
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
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
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
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
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 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
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
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
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
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
Nov 14, 2010
I have an Activity which is an OpenGL view. I also have an xml layout to use for preferences. Until now, to show the preference menu, I just brought it to front by setContentView(). And the same to get back to the OpenGL view. But is this a case where I should give the preference menu its own Activity? I guess this would make a few things much easier. For example, the back button would just work, opposed to now where I have to code it or it will just exits the application.And if this is a good idea, how do I pass data both ways? I have a class that store all preferences. Can I send it to the Activity and back again? Or is the best way to store the preferences in a sqlite database and then use it for passing data?
View 2 Replies
View Related
Apr 22, 2009
I have read 'http://developer.android.com/guide/tutorials/notepad/notepad-ex2.html', specifically step 4 ahow can I return a different result to the 'calling activity', in this example, it always return ACTIVITY_CREATE. What if the 'activity being launcher' has a 'okay' and a 'cancel' button. How can the 'calling activity' knows which button user presses in the 'activity being launcher'.
View 3 Replies
View Related
Aug 15, 2010
Right now I have 2 activities (A+B) and what I would like is for only 1 of them ever to be on the stack (If A shows B, I want the back button from B to go to the home screen not A). Is their a good way of doing this with activities Or should I change my app to be a bunch of views?
View 5 Replies
View Related
Apr 15, 2010
In my project ,I need get all the name of the activities ,not only my own application, but also the third party application , and how can I get?
View 3 Replies
View Related
Aug 20, 2009
I have an application with three tabs. Through various interactions with the items in the tabs I end up launching other activities. The client has reviewed this and would like the activities launched "within" the tabs, so the tabs remain visible and if the user clicks the tab it goes back to the original activity defined in the setContent function. Is this possible and how would I go about this from other activities? (ie the child activities, not the one that defines the TabHost and has access to call setContent)?
View 4 Replies
View Related
Feb 8, 2010
I have a very simple game that consists of only one activity, and I want to add a title screen.If the title screen is another activity, what changes do I need to make to my manifest file to make the title screen open first?The gameplay activity is called Leeder, and the title screen activity is called LeederTitleScreen.
View 1 Replies
View Related
Apr 3, 2010
when click the grid item, i want to show a progressbar between the time of next Activity shown. then the second activity has a custom listview. there also i want to show a progressbar. how to do that?
View 1 Replies
View Related
Jun 10, 2010
I need to have two activities in an Android app that can be switched between each other with UI persistence.I would like the changes made in step 2 to be visible in step 4.I have tried using the singleInstance activity tag on Activity B to no avail. I would also prefer a more elegant solution than simply writing all object properties to a file or SQLite table.It seems that this behaviour must be easily achievable given that Android does it automatically for calls to onBackPressed() where the parent Activity's UI is saved.
View 2 Replies
View Related