Android :: OnRestart() Being Called After OnDestroy()

Jul 21, 2009

Every once in a while my activity gets restarted after it's destroyed instead of being created again. I.e. I see:

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

instead of:

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

Looking back in my log I can see this happening periodically, but no apparent pattern to it. This certainly isn't in the state diagram, and needless to say this doesn't make for a happy app.

Android :: onRestart() being called after onDestroy()


Android :: OnActivityResult Called Before OnRestart()

May 4, 2009

I am updating some code from 1.1 to run with the new SDK 1.5. I noticed that onActivityResult is being called before OnRestart.

If Activity A calls activity B. Activity A goes to onPause(), then onStop(). Activity B goes on... finishes and returns.

Activity A starts at onActivityResultf(). So if you try to make a clean exit with onStop(), it will cause nullPointers when it comes back.

View 2 Replies View Related

Android :: OnRestart Method Not Called On Restart

Apr 15, 2010

I'm writing a Tetris application on Android for my bachelor thesis at the University of Hasselt. Currently I have a working Tetris base game, but it just keeps on ticking when the activity gets in the background. I'm trying to fix this by overwriting the onStop()and onRestart()methods.when I press my home button on my device I will go to my home screen and onStop() is called. Because the gamemode is now "PAUSE", the game wil not tick anymore. But now, when I longpress my home button and select my tetris activity again, the activity pops up, but it isn't ticking! This is because the onRestart() is never called when I return to play my application.What is the reason that this method is never called? Am I understanding the activity lifecycle wrong?

View 3 Replies View Related

Android :: OnStop OnDestroy Called From Back Key Or Not ?

Sep 17, 2009

Each time I switch the orientation of the device, onStop() and onDestroy() are called. They are also called when I close the Avtivity (dismiss()), and when I press 'back' key. In onStop() or onDestroy() methods : how can I know how I can here ? I'd like to run some code when I close the Activity (back button), but not if I change screen orientation

View 7 Replies View Related

Android :: OnDestroy Not Called After Adding Texttospeech

Apr 13, 2010

I added TextToSpeech to my app, following the guidelines in the following post:

http://android-developers.blogspot.com/2009/09/introduction-to-text-to-speech-in.html

and now my onDestroy is no longer called when the back button is pressed.
I filed a bug report regarding this: http://code.google.com/p/android/issues/detail?id=7674

Figured i should also ask here if someone else has seen this, and found a solution?

It seems that it is the intent that causes the problem, i.e. the following:

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

If I skip this intent, and just go ahead and create a tts-instance, it works fine.
Any clues to what is wrong with this intent?

View 2 Replies View Related

Android :: OnActivityResult No Longer Being Called After OnDestroy

Jul 3, 2010

OnActivityResult is giving me major headaches. My little game has a title / menu screen. Upon clicking "new game" an Activity is launched which creates a SurfaceView for my game world.

When playing, the player can enter buildings in the game world. Upon entering a building I launch the activity for that particular building from my SurfaveView.

Here is an example:

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

mMap is the SurfaceView. I'm passing a bundle containing the state of the player. In onActivityResult I grab the bundle returned by the store activity and update the player state.

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

mSavedPlayer is later used to set the new player state.

All the above works generally

I can enter stores, buy stuff, leave and the player is updated correctly.

The problem manifests when I press the Home button (or someyimes back button) and onDestroy gets called. My onDestroy method does nothing besides call super.onDestroy();

After onDestroy() gets called onActivityResult no longer gets called.

So:

1) I play the game, everthing works great.

2) I press home and ondestroy is called

3) relaunch my game via launcher icon

4) Resume game. I can still enter and leave stores but onActivityResult is no longer called.

Here is some logcat output. I'm logging each time I enter a relevant method.

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

View 1 Replies View Related

Android Fragment OnDestroy Called Twice During Orientation Change?

Jan 19, 2014

why onDestroy is being logged twice for the fragment class in the the following code when the orientation of the device changes. Its logged once for the activity class, but twice for the fragment.

Code:
public class ExampleActivity extends Activity {

protected String LOG_TAG = ExampleActivity.class.getSimpleName();

private FrameLayout mFragmentHolder;[code].....

View 1 Replies View Related

Will OnStop And OnDestroy Always Get Called

Sep 28, 2012

There are some process manage application that allows user stop any running aplication by a button pressing. I want to know, in these situations, the onStop and onDestroy methods will always get executed?

View 6 Replies View Related

Android :: Simple App Crashes On OnRestart() / Fix It?

Oct 3, 2010

I've been writing a simple drawing App as homework for university. Drawing works fine, but the canvas should also be cleared when the App is coming back from the background. When switching back i get the following code...

View 2 Replies View Related

Android :: Android 1.5 - Asynctask DoInBackground Not Called / Method Called

Oct 26, 2010

I am running into an issue with the way my asynctasks are executed. Here's the problem code:

firstTask = new background().new FirstTask(context);
if(firstTask.execute().get().toString().equals("1"))
secondTask = new background().new SecondTask(context);

What I'm doing here is creating a new asynctask object, assigning it to firstTask and then executing it. I then want to fire off a separate asynctask when the first one is done and making sure it returns a success value (1 in this case). This works perfectly on Android 2.0 and up. However, I am testing with Android 1.5 and problems start popping up. The code above will run the first asynctask but doInBackground() is never called despite onPreExecute() being called. If I am to execute the first task without the get() method, doInBackground() is called and everything works as expected. Except now I do not have a way to determine if the first task completed successfully so that I can tell the second task to execute. Is it safe to assume that this is a bug with asynctask on Android 1.5? Especially since the API says that the get method has been implemented since API 3. Is there any way to fix this? Or another way to determine that the first task has finished?

View 2 Replies View Related

Android :: Releasing Resources In OnDestroy

Aug 20, 2010

I understand that the system may kill the activity without calling onDestroy(). Say I have a MediaPlayer that runs even when it's not visible, I would be releasing the player in onDestroy() method.Now, if the system decides to kill the activity after calling onPause() and never called onDestroy(), what does it mean for my MediaPlayer? Is it ever released? This is bigger problem for Camera since I think it requires to be released for other activities to use it.

View 1 Replies View Related

Android :: Service.onDestroy() Invalid?

Sep 30, 2009

I use AlarmManager to restart my service, code is:

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

After 5 seconds, BootCompleteReceiver will startServcie(), but only see onStart() not onCreate() calls.

Is the way of destroying the service wrong? BootCompleteReceiver is written in AndroidManifest.xml

View 2 Replies View Related

Android :: Testing Low Memory And OnDestroy

Jun 21, 2010

Testing onDestroy.

Q: does using a lot of RAM in one application always lead to onDestroy being called on Activities in other applications?

To try and figure this out I created two separately installed applications. The first just logs its lifecycle transitions and the second allocates a chunk of memory each time you press a button.

What I saw was the second application eventually suffered a fatal Out Of Memory Error force close. The onDestroy method was not called on the first logging application and when I switched back to it onResume was called.

My conclusion is that using a lot of memory in a single application will lead to a fatal Out Of Memory Error without onDestroy first being called on Activities in other applications. The documentation left me expecting an onDestroy on the logging application since the foreground application was trying to allocate more memory.

Does the above sound right? What's a good way to test the onCreate/ onDestroy lifecycle methods as they relate to low memory?

View 2 Replies View Related

Android :: Content Provider OnCreate OnDestroy

Jun 30, 2010

when writing a ContentProvider I have to implement the onCreate()-method, in which I establish my database connection. But to write the changes I made to the database I have to close the database on some point. Does something like a onDestroy()-method exist for ContentProviders or is there some intent I have to listen to, which is fired before killing my process?

View 5 Replies View Related

Android :: Hide Activity On BACK Key Without OnDestroy?

Oct 28, 2009

When user presses BACK key, my activity's onDestroy is called and then it is killed. Is there a way (by overridding Activity.onKeyDown??) to simply put the activity into background without killing it? I want the BACK key to act like the HOME key (which doesn't kill my app), except I want to show the activity immediately below my activity.

View 7 Replies View Related

Android :: Service Dies Without Calling OnDestroy

Dec 15, 2009

A service is setup by an activity with startService(service_intent). This service is meant to run 24 hours a day. After some amount of time, 5 or 6 hours sometimes but its not predictable, the service is killed.In the database log, the destroyed message does not show up and the notification #1 is not cancelled. Android makes no attempt to restart the service. The database log will show the startup of the replacement service if I trigger it by visiting the activity. What can I do to keep this service running or at least get it restarted by android automatically?

View 6 Replies View Related

Android : Listener - Back Button - And OnDestroy

Mar 13, 2010

I have an application with a single Activity implemented as a singleton (in the AndroidManifest). It implements a Listener I wrote. When the application is first run the Listener works fine. When I use the "home" button to minimize it, then open it again it's still fine.

But when I press the back button then run it again from the application icon, the Listener doesn't work fully. The code runs and the Listening methods are called as usual but none of the UI elements that are listening update. It requires a restart of the phone to get the listener working again after this point.

I know the "back" button doesn't really close the application, per se. But resetting the phone sure does! Is there a way to use the onDestroy() or similar method to call a function that actually closes the application? I'm asking because restarting the phone is the only way to get the listener back so I was hoping I could do that programmatic ally.

For example, my progress bar is a member variable of my Activity, but onCreate() I do "progressBar = (ProgressBar) findViewById(R.id.progress_bar);" Is this perhaps creating a separate instance of it or something?

View 8 Replies View Related

Android :: Order Of Statements In OnDestroy() Method

Feb 3, 2010

If I override my main Activity's onDestroy() method in order to recycle a bitmap when the screen is rotated, should I call super.onDestroy() before or after myBitmap.recycle()? Does it matter?

View 1 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 :: Two OnCreate (and OnDestroy) Invocations On Orientation Chage

Jan 4, 2010

With following simple code (on clean, new android project):

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

View 5 Replies View Related

Android :: Why Does App Not Get OnDestroy When Exited But Then Receives An OnCreate When Relaunched

Sep 11, 2009

Why does app not get onDestroy when exited but then receives an onCreate when relaunched?

Here is the trace. Launched app

It received onCreate and the other expected on calls for a launch. Now, leave application with the home button and it receives onSaveInstanceState onPause onStop

And returns to the main Android screen (the one with Google Search at the top) Launch the app again and it receives onCreate onStart onResume

The docs say onCreate is Called when the activity is first created. But here it is never destroyed but created again. There are many objects that never got GCed because the app was not onDestroyed?

Is this a memory leak? What have I missed? Or should I assume that onCreate can be recalled for an already created app.

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 To Save Value OnDestroy Or OnStop / Program Launches Back Again?

May 6, 2010

I wonder if I could save a value (in my program its an index) so I could call it back when the program launches back again (even if the program destroyed) and the user could start from where finish.

View 2 Replies View Related

Android :: Implementation Of OnDestroy For Service Containing Worker Or Backround Thread

May 26, 2009

I'm implementing a service that contains a thread to handle all time consuming operation. My core service logic is in a different thread than the ui or main thread. According to the Android document, when the OS plans to free some system resource, it will call onDestroy () on the service and only when onDestroy() returns it will kill the process hosting the service, thus giving opportunity to the service to cleanup.Now, when onDestroy() is called, I want to send a message to my service thread to do the necessary cleanup. Only when the service thread acknowledges that the cleanup or shutdown is complete, onDestroy () should return. I could find a way to send asynchronous messages to threads and the corresponding processing of the messages, but not able to figure out how I need to implement onDestroy(), such that it would send a message to the service thread and should wait for a result, before returning.

View 13 Replies View Related

Android :: Activity Execute OnDestroy() / OnCreate() Method When Push On Keyboard

May 2, 2009

I use sdk 1.5 version and same to my handphone, my handphone is use G1. Now i test my application on my handphone. When i push on keyboard, i found system will destroy current activity(execute onDestroy() method) and execute onCreate() method again. So i will all current status and all datas. I don't wish this happen, how to block system execute onDestroy() and onCreate() when i open and close keyboard?

View 2 Replies View Related

Android :: Unbind Remote Service In OnDestroy Of Activity On Screen Orientation Change

Nov 24, 2010

In onCreate method of Activity, it binds to a remote service and makes use of AIDL intefaces. Is it required to unbind from the remote service when onDestroy is called on screen orientation change.?

If the activity un-bounded from the remote service in onDestroy and if no other contexts are bound to remote service, is remote service likely to get stopped losing the state that it maintains.?

View 1 Replies View Related

Android :: Android Weird OnCreate / OnDestroy Balance

Sep 25, 2010

is there a way to tell Android that I would like subsequent calls to startActivity() all resume the target activity rather than creating it over and over again? Any workarounds?

View 1 Replies View Related

Android :: How To Called Mp3 Download?

Jun 4, 2010

I was reading through app suggestions and someone mentioned an app called mp3 Download that basically functions like limewire, letting you search and download mp3's to your phone. Does anyone know anything about this app and whether it is good or not? Or have suggestions for a similiar app? It had mixed reviews at appbrain and when I searched here it came up with a bunch of other threads.

View 4 Replies View Related

Android :: An App Called Listen?

Sep 22, 2010

I was told by a few friends that the iphone has an app that allows you to hold your phone up to a song that you dont know and it tells you the name.Does android have anything like that?

View 6 Replies View Related

Android :: OnKeyDown Not Always Called In App

Oct 20, 2009

I've created a simple android game, based on the Lunar Lander sample, and I'm having a problem with handling key events.When the activity starts, the only keys that onKeyDown or onKeyUp get called for are the dpad up/down/left/right keys.Neither the menu, back, or dpad_center keys trigger onKey methods. However, once I've pushed one of the dpad up/down/left/right buttons, pressing the menu, back, or dpad_center keys do trigger these methods. I'm not getting any errors, or any indication of what's going wrong.It's possible that the focus is set wrong - the activity is started from a button on screen, so it could be in touchscreen mode. If that's the case, shouldn't touching the back button get me in to the right focus mode so that I can catch the event?I'm using the emulator from SDK-1.5r3.I have not been able to try this on a real phone yet.

View 4 Replies View Related







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