java - Android - Activity finish() results black screen -
i have alertactivity
, activity
. when broadcast received, both activities needs finish. below code results black screen if alertactivity
on top of activity
.
below code in activity
:
private final broadcastreceiver mreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { if(intent.getaction().equals("broadcast_intent")){ if(alertactvity != null) alertactivity.finish(); finish(); } }
and code in alertactivity
:
private final broadcastreceiver mreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { if(intent.getaction().equals("broadcast_intent")) finish(); } }
first, activity's onstop()
getting called before alertactivity
's onstop()
called results in black screen, alertactivity
's finish()
called before activity
's finish()
.
please me in regard.
finally, found solution this:
finishing activity
delay of 1 second works. time, alertactivity
finishes , black screen cannot displayed.
new handler().postdelayed(new runnable() { @override public void run() { finish(); } }, 1000);