Hi,
I have a problem with activities that contains mapView. When ever activity contains mapView on BACK button pressed instead of finishing only said activity, parent activity is finished too, without explicit finish call.
For example:
Main -> ActivityB (if ActivityB contains mapView on BACK app is closing because BACK on ActivityB closes ActivitB and Main)
Main-> ActivityA -> ActivityB (on BACK on ActivityB closes ActvityB and ActivityA and stays in Main activity).
finish method of any activity is not overridden.
Any suggestions?
are u using onBackPressed() method? if yes just call finish() inside this method.
for better solution just paste ur code here.
Thanks
Rhitz
Thank you very much for your response Rhitz.
Yes, I am using onBackPressed method. Here is the code:
@Override
public void onBackPressed()
{
this.finish();
}
Also, in meantime I tried to override finish method:
@Override
public void finish() {
if (this.progressDialog != null && this.progressDialog.isShowing()) {
this.progressDialog.dismiss();
}
if (this.returnGeometryTask != null && this.returnGeometryTask.getStatus() == android.os.AsyncTask.Status.RUNNING) {
this.returnGeometryTask.cancel(true);
}
}
This makes no difference.
Thanks,Mladen
I would suggest not over-riding the onBackPressed() or finish() unless absolutely necessary. If your concern is to make sure a background thread is stopped it would be better placed in onStop(). Moving your logic there would always ensure the process is stopped rather than in finish() which may not be called.
Activities | Android Developers
...
Activity
object is retained in memory, it maintains all state and member information, but is not attached to the window manager). However, it is no longer visible to the user and it can be killed by the system when memory is needed elsewhere.If an activity is paused or stopped, the system can drop it from memory either by asking it to finish (calling its finish()
method), or simply killing its process. When the activity is opened again (after being finished or killed), it must be created all over.
Thank you for your response,
The selected combination of device + Android version is important because our client has a number of devices purchased with a package deal from the provider.