Android :: When Does Activity Object Really Get Killed After Calling Finish()

Nov 5, 2010

I created a thread in my activity, and that thread will print out the value of my instance variables in my activity after running for about 10 seconds. I pressed the back key to destroy my activity before the thread prints out the values, and when the thread reaches that line of code, it can still print out the values correctly. That means even though the activity is finished, the java object of the activity is still there. Will the object always be there? Or it is just waiting to be GCed? Or it will be killed only when Android needs memory?

Android :: When does activity object really get killed after calling finish()


Android :: Calling Finish() After Starting A New Activity

Apr 26, 2010

The first Activity that loads in my application is an initialization activity, and once complete it loads a new Activity. I want to ensure if the user presses 'Back' they go straight to the Launcher, and not the initialization screen. Side note, is this even the best approach, or would this be better done with some kind of Intent Flag?

Is it correct to call finish() after calling startActivity() on the new activity?

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

I'm still taking in the whole 'Message Queue' method of doing things in Android, and my assumption is that calling startActivity() and then finish() from my first Activity's onCreate() will log each respective message in the message queue, but finish execution of onCreate() before moving on to starting the next Activity and finishing my first one. Is this a correct understanding?

View 1 Replies View Related

Android :: 1.5 And 1.6 After Calling Finish Activity And Home Button

Jan 12, 2010

I open splash screen at the end i call finish() then i moved to browse page. At the browse page when i click on home button it hide the application.(b/c of Android's Multi tasking feature) When i go to Android's desktop launch application again it starts from splash screen. Android Platform 1.6

I open splash screen at the end i call finish() then i moved to browse page. At the browse page when i click on home button it hide the application.(b/c of Android's Multi tasking feature) When i go to Android's desktop launch application again it always starts from browse screen instead of splash screen why is that..............

View 1 Replies View Related

Android :: Return To Previous Activity Without Calling Finish() / Save This Information?

Oct 26, 2009

I have an android application with a LOT of activities, think of something like a book where every page is a new activity. The user can make changes in each activity, for example highlight certain texts with different colored markers etc. and it's crucial that I'll remember this information as long as the application stays alive (and I don't want/need to remember any of this when it's not). As I understand the best mechanism for storing this kind of information is via onSaveInstanceState(Bundle outState) and onCreate(Bundle)/onRestoreInstanceState(Bundle) rather than lets say, the Preferences mechanism. My only problem is that the user can navigate backwards to previous pages (Activities) and the only way i know of achieving this is by calling finish() which of course kills the current activity without calling onSaveInstanceState(Bundle outState) and even if it did call it, the next time I would launch an activity representing that page it would be an entirely new instance. So my question is: Is there a way to go back to the previous activity without calling finish()? or, is there a better way to save this information? maybe through static variables?

View 1 Replies View Related

Android :: Insufficient Memory Error When Launching Application For Second Time After Calling Finish - In Main Activity

Apr 21, 2009

I have made a game with just one activity.. I just replace the views when I want to change screen. The game runs fine for a really long time inspite of what ever I do within the game.

But once I close the main game, by calling finish on the only activity in the application, and then when I start again, within the next 30 secs it crashes telling VM budget exceeded..

When I don't have a dispose() or a delete method in JAVA.. how the, am I supposed to remove the objects used in memory.. moreover I have android:launchMode="singleInstance" in my manifest

View 4 Replies View Related

Android :: Activity Finish Method Waits To Finish?

Aug 14, 2010

With this sample code, the activity is told to finish, but continues execution afterwards and displays the message. I'm trying to understand why this happens. The only fix I can think of is to place 'return' after finish.

public void someMethod() {
if( valueIsTrue) {
startActivity(new Intent(this, NewActivity.class));
CurrentActitivy.this.finish();

// return; // if uncommented, Toast doesn't show
}
Toast.maketext(this, "Some message", Toast.LENGTH_SHORT).show();}

View 1 Replies View Related

Android :: App Does Not Quit On Calling Finish() / What's Cause?

Apr 28, 2009

I have been developing a game on Android and wrote a wrapper for J2ME classes,

When notifyDestroyed() is called in my ME program and calling finish() but the application doesn't close correctly.

The App goes to background and when launched again it shows an error message and presents an option to "force close" the App, if i force close it and launch again, the app launches fine but again the same has to be repeated upon every launch..

Can you please explain why the App is not being erased from memory when finish() is called.

when i check the log i found no exceptions when closing but when launched again it throws a null pointer exception.

for now to work around I placed "System.exit(0)" after calling finish () so that the app is exited abruptly, but am waiting for a valid answer on whats going on behind...?

View 9 Replies View Related

Android :: Calling Finish() In OnResume()?

Sep 8, 2010

I've been using code like: activity.finish(); activity.startActivity(new Intent(activity, activity.getClass()));

in two places: onResume(), and in an onClick() method of an AlertDialog. I'm getting the desired results when the code is called from onClick(), but I get mysterious null pointer exceptions while the runtime is trying to execute my onPause(). Is calling finish() from within one of the Activity lifecycle callbacks always a bad idea?

This code makes me nervous even though it works in the onClick(). After I call activity.finish(), I would think activity is in a questionable state by the time activity.startActivity() is invoked. Seems like an invitation to race conditions.

My use case is setting UI preferences (e.g. a different layout) in a PreferenceActivity. When I return to the main activity's onResume(), I check for preference changes and if a new layout is requested, I use the code snippet above.

View 10 Replies View Related

Android :: Shouldn't Calling FinishActivity Cause Finish To Be Called?

Nov 11, 2010

I have overridden the finish call in a sub-activity like so

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

I am calling finishActivity on this sub-Activity from the Activity that started it for result. But I am not seeing the finish being hit. Instead it goes directly to onPause.

View 2 Replies View Related

Android :: OnStop And OnDestroy Aren`t Invoked After Calling Finish()

Oct 14, 2010

i`ve got some problems with finish() method. I expect what after calling on my Activity finish() method onStop and onDestroy must be triggered(or am wrong??), in majority of examples they are, but Scenario: - reboot phone - launch activity - invoke finish() onPause is triggered but afterwards they are no calls to onStop() and onDestroy()I`ve noticed, that those calls are triggered after launching any other activity.

View 7 Replies View Related

Android :: How Can I Get Current Activity Object In Instrumentation Object?

Sep 9, 2009

I want to do some automated testcase with Instrumentation . Suggest that my AUT has 2 Activity. After clicking the button in ther first Activity, the second one will be shown with new content base on what we enter in the first Activity.) Instrumentation provides us the function called startActivitySync() and return the Activity object for processing. My question is how we can get the pointer of the second Activity after the it is shown by clicking the button on the first activity.?

View 2 Replies View Related

Android : Closing Activity Completely / Process Killed By Activity Manager Service

Aug 2, 2010

Whenever the memory needs to be reclaimed, the process is being killed by Activity Manager Service in killPidsForProcess. I have a back button in my activity window on right corner of the title bar.

I want to kill the activity completely on clicking the close button. Can I reuse the same function and will it have any major effect? Please help me out in this.

View 3 Replies View Related

Android : Get Activity Object From Intent Object

Sep 21, 2009

I have an Activity that running on system. I can get the Intent that is used to start the activity. But i don't know how to get the Activity object from the Intent object or something else. Can anyone tell me how to do this??? Note that, I don't use Instrumentation object.

View 11 Replies View Related

Android :: Finish Any Previous Activity In Stack From Current Activity?

Apr 27, 2010

How to finish any previous activity in application stack (at any level , I mean not immediate parent) , from current activity like on some particular event I want to invalidate this previous activity?

View 1 Replies View Related

Android :: Finish Activity Not Started From Current Activity

May 1, 2010

I have following problem with my application: From my main activity ("activity 1"), there is a menu from which user can launch an action. This action will result in an Intent being received by a BroadcastReceiver, defined in my application. Finally, this BroadcastReceiver will start an activity ("activity 2") to deal with this intent.

The problem is that I have a "quit application" entry in my menu, and I can only finish() currently active activity. ie I am not able to finish "activity 1" from the menu of "activity 2". And I can't use startActivityForResult() as "activity 2" can't be started from "activity 1". Any suggestion would be much appreciated Thank you very much guys, regards.

View 4 Replies View Related

Android :: Finish Activity From Other Activity

Oct 8, 2010

I am having application in which i am using menu , on tap on menu item i am redirecting to specified activity. I want to make sure that when i am redirected to another menu item my current all activity should be finished to reduce the stackflow of the activity and better performance. So when i tap on back from my tapped activity from the selected menu activity i should be redirected to another activity and finish current activity. So i am wondering is there any way by which i can finish another activity from my current activity. Or should i override the OnKeyDown Method..

View 1 Replies View Related

Android :: Service Gets Killed - Due To Activity?

Jun 10, 2010

I have a service running in the background. It starts on device boot. Also, I have one activity (that appears in the task launcher) in which I have provided buttons to start and stop the service.

Now, I install the application on the phone and I start the service using this activity (and not on-device boot). As expected the service starts and starts doing its designated task. I no-longer need the activity. So it goes out of sight and may not be required for a long time now.

My question is, now, if the android platform kills this activity, will it kill my service too ? (This is because I see that after few hours, my service is not running anymore.). If this is true, then will the service continue running longer if the service was started on device boot.

View 11 Replies View Related

Android :: How Finish An Activity In This Instance

Aug 16, 2010

We all know that hitting the back button on the device doesn't kill the application, it merely finishes (destroys) the activity running on the foreground.

Well I have come across some code which helps me capture the back button signal so that I cannot exit the application. The only way to exit it in such cases is to press the home key.

Now this situation presents me with a unique disadvantage! The inability to kill finish the application on a time of my own choosing allows the application to keep running in the background like nothing has changed.

So in such cases is the task manager my only friend or is there a way for me to otherwise kill this application?

View 2 Replies View Related

Android :: Activity Pause Rather Than Finish?

Nov 30, 2009

I see no means by which my activity can pop itself off the activity stack to return the user to the one he was using before it was invoked. Is there one? My purpose is that my app has some data structures built from data provider queries that take 5-15 seconds to assemble and I don't want a lot of latency if it is used in a few one-shot purposes in rapid succession. I'm more than willing to let the system ask my app to die, but I'd like to keep warmed and ready otherwise.

View 4 Replies View Related

Android :: Wait For Activity To Finish?

Sep 7, 2010

I have one activity call a camera view activity, and in the onActivityResult, I have it start that activity again with different parameters. Android doesn't seem to like that, and gives me an error that the camera is not available if I start it right after it returns. I tried just waiting a few seconds, but this doesn't seem to work on all phones, and it sometimes crashes. Is there some way to wait until that activity finishes properly, and gives up all resources?

View 6 Replies View Related

Android :: Finish Not Killing Activity

Apr 12, 2009

I've got an application that has (among other things) three Activities, let's call them A, B, and C. A is the main navigation point for the entire application, and launches B and C directly using startActivity(). They work fine that way. However, when I call C from inside B, I get a strange problem. The code for launching Activity C is exactly the same in both places. The problem is the hardware back button. In the emulator, it takes two presses of the back button in order to close Activity C and come back to B. On a G1, it takes 3 or 4 presses. Upon seeing this, I implemented the usual suspects in C - onPause(), onStop(), and onDestroy(), and onResume() in B. When I press the back button from C and it doesn't work, I get onPause(), onStop(), onDestroy () - in that order, but nothing happens. When it works (on press 3 or 4 on the G1), I get onPause(), then onResume() in B, then onStop() and onDestroy().

I've tried catching the key press of the back button and calling finish (), but that doesn't make a difference. Has anyone seen this? To pre-empt some questions: All C does is display some data. There are no threads or any other special resources that C might have an active handle to that's preventing it from closing. But out of curiosity, if it did, how would I detect that? Any ideas for further diagnostics here?

View 12 Replies View Related

Android :: Finish() Won't Close Activity

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

Android :: Activity Being Killed - OnDestroy - On Orientation Change

Apr 5, 2010

I am working on a MVC implementation for Android (to be subsequently hosted on SF and/or GC).

It works like this:

Activity (View) <=> Application (Controller) <=> Data (Model) <=> Persistence (DB/Network etc)

The scenario is:

1. Activity launch (main/launcher)

2. Notifies Application about performing a data transaction

3. Upon receipt of data response, controller devices which Activity to launch (or update existing)

4. Application has overridden the method onConfigurationChange

Problem: When the orientation is changed, the Application is notified about onConfigurationChange but:

a) The "current" activity is Destroyed and recreated -- which is fine to some extent b) The new instance which is created is automatically => onCreate, onPause, onStop, onDestroy.... now that's catastrophic.

View 4 Replies View Related

Android :: How To Get Calling Activity Instance From Called Activity?

Jul 9, 2010

I have a Contact Activity which is derived from ListActivity, which displays list of contacts, and on click of item, a new Activity Message Activity derived from ListActivity is initialized.Now I know, I can pack some information in Bundle and pass it before creating activity, but is there a way I can get instance of "ContactActivity" in onCreate method of "MessageActivity"?

View 1 Replies View Related

Android :: Finish Activity Doesn't Work

Nov 5, 2009

In main Activity, I called start Activity For Result(intentB, 100) to start a new activity B, then in B, I called startActivity(intentC) to start another activity C. Lastly I wanted to call finish Activity(100) in C to close activity B, but seemed it was not successfully destroyed(I can use BACK key to see it's still there.)

View 6 Replies View Related

Android :: Finish Activity When Home Pressed?

Mar 25, 2010

I saw another thread related to this question, but did not find the answer that was useful to me. Is it possible when the user presses the Home button to be able to finish() my activity somewhere? I saw that people were having problems with using onStop(). Has anyone found a resolution to see if this is always called on Home being pressed?

View 5 Replies View Related

Android :: Finish Child Activity From Another In Droid?

Sep 14, 2010

I have a parent activity (as ACTIVITY GROUP) and some child activity of this parent activity (as ACTIVITY).
I am just calling child1 now i want to move from child1 to child2 and just want to finish() child1.
But when i am calling finish() it is also finishing the parent activity.

View 1 Replies View Related

Android :: Does Pressing Back Always Cause Activity To Finish()?

May 10, 2010

I've heard that pressing the back button will essentially cause the current Activity to finish(). Is this always the case? Seems like it would be with the way it pops the Activity off the stack.

The one situation I'm not so sure about is when the root Activity in a Task has back pressed. I'm currently experiencing a very weird effect, described as follows:

On loading my application, the first Activity is for initialization, and once it finishes, it calls my main Activity (a TabActivity). This first init activity has android:noHistory="true" set in the Manifest so pressing Back from my main Activity won't go back to that. It goes to the Launcher. When I click on my App in the Launcher a second time, the initialization activity loads again, and loads the main Activity when done. Almost immediately after, it loads a second instance of my main Activity. But ONLY after the Application has already been run once, and was exited by pressing BACK from the main Activity. It does it every subsequent time until I force quit the app or load a new version from the IDE.

Based on this, I am suspecting some kind of Activity instance is lying around and being reused, since it only happens on the second+ time I run the application (and exit with BACK -- using HOME just returns to the last state of the app, no big deal).

View 4 Replies View Related

Android :: Finish Activity From Custom BaseAdapter

Nov 22, 2010

In my android application I have custom listview with an image and textview. In extended BaseAdapter under getView method click events of textview and image are associated with onClick method using setOnClickListener as shown in code below

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

And

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

When clicking on image it acutally deletes that entry from List which works fine, but on clicking textview i would like to return the text of clicked textview to main activity but I am unable to achieve this, although I can do this from setOnItemClickListener of this custom listview acitivity.

View 1 Replies View Related

Android :: Finish Parent Activity From Child?

Mar 30, 2010

My child activity X is called from Parent activity P through startActivity(intent). I want to close P when X called its finish() method. I override a method finishFromChild(Activity child) in P and called finish() in it. But this functions (finishFromChild(Activity child)) is not being called after X finish() Is it a known bug or I am missing some thing? I googled and also searched the groups but no help.

An alternative could be... using StartActivityForResult() and a "fake" onActivityResult, where I can finish the parent activity, but this way is quite bad, i think...

I prefer the first one, if it would work....

View 3 Replies View Related







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