Reputation: 4595
I have Activity A that starts another Activity B.
When I am in Activity B I should be able to close both A and B.
For this purpose I used the approach at this link https://stackoverflow.com/a/11509279/1815311, but sometimes I get a NullPointerException
when I do aActivity.handleToClose.finish();
Please what possibly can be wrong here???
Upvotes: 1
Views: 58
Reputation: 4897
That happens because your Activity A is closed form some reason and when you call you method to close that activity you get null pointer exception.
The solution is to check if Activity A is finished or not, if it is finished than you dont need to call finish
Upvotes: 1