Gokul Rajkumar
Gokul Rajkumar

Reputation: 115

How to close a activity and exit the app in background when a button is clicked in Android in this scenario below?

I am developing a Chat App, the app is in closed state. The Caller A makes a Call to another user B. The User's B app open, IncomingCallActivity.java there is reject call button, when reject button is clicked the call get disconnected but the app is not closed. The IncomingCallActivity always remains in minimised state. How to handle this?

Upvotes: 3

Views: 646

Answers (1)

mostafa3dmax
mostafa3dmax

Reputation: 1017

you should set excludeFromRecents to true for your IncomingCallActivity in Manifest file :

<activity
    android:name=".IncomingCallActivity"
    android:excludeFromRecents="true">
</activity>

or you can set flag to intent that opens IncomingCallActivity :

Intent incomingCallActivityIntent=new Intent(this,IncomingCallActivity.calss);
incomingCallActivityIntent.addFlag(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(incomingCallActivityIntent);

and after call finished call finish() method

Upvotes: 4

Related Questions