Abid Khan Abid Khan - 2 months ago 19
Android Question

Android clear activity from memory

In my app I have a SIP calling feature.
When the app is not opened and it is cleared from the system memory and it receives incoming call it opens the call activity from a SIP service.
When the call is disconnected, I finish the activity.

But the issue is, the activity is still in the memory (when home button is pressed).
I want that activity to not be in the memory.
Like whats app call behavior that don't keep activity in the memory when the app was killed
i.e., not in the memory.

From SIP service I call it like this.

Intent intentIncomingCall = new Intent(getApplicationContext(), CallActivity.class);
intentIncomingCall.putExtra("DisplayName", callerDisplayName);
intentIncomingCall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentIncomingCall);


and on call disconnect, I just simple stop the service and call
finish()
on activity.

I have tried adding flags and exit(), things but nothing works.

Answer
 android:allowTaskReparenting="false"
        android:excludeFromRecents="true"
        android:launchMode="singleTask"
        android:permission="android.permission.USE_SIP"
        android:screenOrientation="portrait"
        android:taskAffinity=""

Try adding above properties to activity in manifest