I am making a quiz app. And I want that if the user kills the app their performance be uploaded on the firestore. When he clicks submit Button everything works fine but when I call submitbutton.callOnClick(); in onDestroy() some code is executed but the data is not uploaded.
this is my onDestroy() code
protected void onDestroy() {
Log.d(TAG, "onDestroy: ------");
if (clicked) { }
else
{
clicked = false;
submitButton.callOnClick();
}
Log.d(TAG, "onDestroy: done");
super.onDestroy();
And this is some code of submitButton 's onClickListener
Log.d(TAG, "onClick: ----------------------");
Result result=new Result(new String(ansString),new String(officialAnsString),correct,incorrect,not_attempted,marks);
FireBase_Variables.db.collection(tName+"_result").document(currentUser.getUid()).set(result);
Log.d(TAG, "onClick: ----------------------");
I can see the upper log in the logcat but not the lower one. Which means the line for uploading data is not executed.
What should I do?