So I have a problem with getting an activity to finish and go back to its parent(right term?) activity.
It gets to this thread ActivityThread.performResumeActivity(IBinder, boolean) line: 2241
and then gives me an InvocationTargetException.(Throwable) line:50 with the following error
java.lang.RuntimeException: Unable to resume activity {com.android.market.companionpushup/com.android.market.companionpushup.WorkoutActivity}: java.lang.IllegalStateException: database /data/data/com.android.market.companionpushup/databases/Exercise Data already closed
So I guess I’m confused, how do I have an error dealing with my database when its just trying to finish my activity and go back to the original activity (but never hits onResume method in original Activity).
The code that was called to start the new activity
public void takeRest(int time, int addTime) {
Intent i = new Intent(this, TimerActivity.class);
i.putExtra("time", time);
i.putExtra("addTime", addTime);
startActivity(i);
}
Then my custom timer runs until I click this button to skip the rest of the timer. At that point it never goes back to the original activity (I have set breakpoints at onCreate, onStart, onResume, onActivityResult), none of the breakpoints are ever reached without the error.
Button skip = (Button)findViewById(R.id.skip);
skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
timer.cancel();
setResult(RESULT_OK);
finish();
}
});
Other code from original Activity, but is never reached when I step through the debugger
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
Toast.makeText(WorkoutActivity.this, "Yay", Toast.LENGTH_SHORT).show();
}
The error tells you what you need to know:
What this says is that the database connection used in the
com.android.market.companionpushup.WorkoutActivityclass has been closed, but was needed for something (refilling a ListView, perhaps?). You should examine youronPauseoronStopcode inWorkoutActivityto ensure that you are not incorrectly closing the database. Are you usingCursorLoaderorstartManagingCursor?