2

In my application onDestroy() method is called while am getting call. How to avoid onDestroy() method is being called on call.

Can someone help me out to get rid of this issue.

Here is my code

@Override
protected void onDestroy() {
    Log.d(TAG,"With in onDestroy()");
    super.onDestroy();
    hotspot.stop(this);
    releasePlayer();
    unregisterReceiver(broadcast_reciever);
}

@Override
public void onBackPressed() {
    super.onBackPressed();
    backPressed();
}

private void backPressed() {
    backPressed = true;
    finishActivity(1010);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            backPressed = false;
        }
    }, 500);
}
asad.qazi
  • 2,449
  • 3
  • 23
  • 35
Archana
  • 378
  • 3
  • 17
  • have you called finish() in your activity?? in onpause or onstop?? or post your activity code. because without call finish() method activity not destroy if any other activity open over it. – Dhaval Parmar Dec 22 '15 at 10:36
  • @DhawalSodhaParmar yes I am calling finishActivity() in onBackpressed(). but that method is called. – Archana Dec 22 '15 at 10:41
  • post your code or read life cycle methods to achieve this – Dhaval Parmar Dec 22 '15 at 10:42
  • `yes I am calling finishActivity() in onBackpressed(). but that method is called` so do not override that method – pskink Dec 22 '15 at 10:43
  • @pskink in destroy am releasing some of the methods. How can I avoid the overriding of this method? – Archana Dec 22 '15 at 10:50
  • `"in destroy am releasing some of the methods"` i have no green idea what it means – pskink Dec 22 '15 at 10:53
  • I am freeing up the memory in onDestroy() – Archana Dec 22 '15 at 10:56
  • @pskink On click of direct home button onDestroy() is not called. But on call its calling and recalling all the activity methods like onCreate(), onResume(), on pause(). – Archana Dec 22 '15 at 10:59
  • it is a normal behavior of every `Activity` read the Activity lifecycle documentation – pskink Dec 22 '15 at 11:05
  • @pskink When we get a call, an activity will be running in the background right? that time we didn't call the onDestroy(). – Archana Dec 22 '15 at 11:09

0 Answers0