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:................................

Android :: onActivityResult no longer being called after onDestroy


Android :: 1.6 - OnActivityResult Is Not Called

Jul 6, 2010

I have a problem with the method "onActivityResult".

I create a new Activity from my main activity:

CODE:.........

The new Activity is ended like this:

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

But the Method onActivityResult seem to be not called

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

View 1 Replies View Related

Android :: OnActivityResult Never Called On ActivityGroup

Jul 21, 2010

I'll be brief. I have an application with the following Activities Schema:

A (ActivityGroup) | |__

B (Activity Group) | | | |__

C (Activity) | |__ ... (Other Activities) | |__

D (ListActivity) | | | |__

ListView with a custom adapter with two buttons per row

All the Activities shown on the "diagram" are displayed and visible in real time while the application is being executed.

I'm pushing new list elements from C to the ListView in D. And by clicking each row's buttons I'm trying to edit the data of the row by means of a dialog. The problem is when, in the dialog activity, I perform the setResult() and finish(); the D's onActivityResult() is never called, and I do not know why.

View 3 Replies View Related

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 :: Does OnActivityResult Get Called When An Activity Is Recreated

Sep 30, 2009

I have a flow A->B->C->D where A desires some information that is obtained by D. B, C, and D propagate the data back through the flow using setResult(RESULT_OK, data) and finish(). All intents in A, B, and C are started with startActivityForResult. However, if B is reclaimed by Android and forced to call onCreate again after C finishes onActivityResult in B is never called and the data never makes it back to A. Is there a way I can be sure that onActivityResult will be called?

View 5 Replies View Related

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.

View 4 Replies View Related

Android :: Recognizer Intent - OnActivityResult() Not Called When No Match

Nov 28, 2010

I have the following issue. I am starting a recognizer intent activity in order to detect speech using the "startActivityForResult" method. I have also an "onActivityResult" method listening for results from the recognizer activity. It works and it detects my speech. The problem is that it is only called when everything is ok or when i cancel the operation, but it is not called if it doesn't find a matching text "RecognizerIntent.RESULT_NO_MATCH" or in the rest of wrong cases "RecognizerIntent.RESULT_........" What is happening? Application is Android 2.1 and I have tested on a Android 2.2 device.

View 1 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 :: Parent Activity Runs OnCreate Before OnActivityResult Is Called - Sometimes

Aug 5, 2010

The order is:

A: startActivityForResult( B ) B: <dostuff>, call finish() A: onCreate <---- what's this all about A: onActivityResult

This happens for a tiny minority of users. I havn't been able to reproduce or find any common elements. A is the launch activity.

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

View 7 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 : Child Activity Exit By Unexpected Exception - OnActivityResult - Is Not Called

Jun 23, 2010

I have faced with issue about startActivityForResult() and onActivityResult(). If child activity started by the startActivityForResult() exit by unexpected exception the onActivityResult() is not called and I have no any ideas how can I handle this to get application working in a fail-safe manner ?

When my code runs child activity with startActivityForResult() it awaits until onActivityResult() will be invoked to get working further, but onActivityResult() is not calling and my code is "hang- up" (logically).

So the question is how can I handle all possible ways the child activity is finished (normally and by unexpected exception) to get fail-safe code ?

I have check the documentation for this issue but have found nothing relating issue.

View 4 Replies View Related

Android :: OnActivityResult Fc When Using SurfaceView?

Sep 4, 2010

My app fc when activity that's using SurfaceView as content view calls startActivityForResult(...) and activity that has been started calls finish()

This does not happen if I change content view to something else than SurfaceView.

This would be the requested logcat:

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

View 1 Replies View Related

Android :: How To Show Alert In OnActivityResult?

Jan 26, 2010

I am trying to show custom alert from onActivityResult. I need to inflate it, so am getting context with getApplicationContext() and everything is fine until I execute alertDialog.show() - then it fails with: Unable to add window -- token null is not for an application Do you know why I cannot do it?

View 1 Replies View Related

Android :: OnActivityResult Doesn't Work ?

Dec 31, 2009

I am facing with a problem related startActivityForResult()

To start SecondActivity from FirstActivity :

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

And handles result :

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

To send the message to FirstActivity from SecondActivity :

in SecondActivity :

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

I can't handle the result on onActivityResult in FirstActivity. It never works for my application.

My OS is : 1.5

View 2 Replies View Related

Android :: OnActivityResult And The Settings Menu

Aug 13, 2010

My app requires a network connection so if they don't have one enabled I prompt them to start it. I do this by calling the Wireless & Network settings Activity as such:

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

However, when I run my app in the debugger, onActivityResult is called immediately as my calling activity is exited when it should be called once the settings menu if exited. This premature call also sends a resultCode of Activity.RESULT_CANCEL.

Here is the code from onActivityResult:

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

View 3 Replies View Related

Android :: Get Tow Intent Result In OnActivityResult?

Sep 17, 2010

I am using two intent for various action in my activity and i also used onActivityResult for get result,i want to answer for how to get tow intent result in onActivityResult?anybody knows please give sample code for me..

View 1 Replies View Related

Android :: Can Pass Uri Value From OnActivityResult() To OnClick() ?

Jul 27, 2010

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

The circle not show.....but when i put the DrawO() next to mSurfaceHolder01.addCallback(EX10_04.this);

It draw a circle!

If i want to draw a circle in the onActivityResult event

What shuld i do?

Or if i can pass uri to onClick function ?

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

View 1 Replies View Related

Android :: OnActivityResult Is Not Working When Used In ActivityGroup

Feb 22, 2010

I have a Activitygroup and some activities are part of it.

lets say Activitygroup is DetailsGroup which has a activity by name DetailsActivity.

On certail events DetailsActivity launches another activity ExtraActivity by calling startActivityForResult(intent, 2);

The extraActivity is launched it does its work and before calling finish() of it I am calling setResult(RESULT_OK,mintent);

By doing this I was expecting that the DetailsActivity's onActivityResult() would be called, but instead DetailsGroup activities' onActivityResult() is getting called.

Any idea what changes are required to get DetailsActivity's onActivityResult() called in above scenario?

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 :: OnActivityResult Intent Data Not Correct

Jul 29, 2010

I'm venturing into startActivityForResult for the first time and I'm running into a problem.When a user clicks on a list item of Activity B, it returns "ql_id" to Activity A:Unfortunately, extras.getInt("ql_id") evaluates to "0". Why is this? It should be "1". I am clearly doing something incorrectly.

View 1 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







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