Ashish Kumar
Ashish Kumar

Reputation: 765

Close Android App programatically in Xamarin Forms project

I am using the following code to close the android app in a Xamarin Form project.

var activity = (Activity)Forms.Context; activity.FinishAndRemoveTask();

It is closing the app but if again I tap on the app it is not opening the new instance of the app as the I can see debugger is still active .

Can anyone help ?

Upvotes: 1

Views: 955

Answers (1)

York Shen
York Shen

Reputation: 9084

it is not opening the new instance of the app as the I can see debugger is still active

When you use activity.FinishAndRemoveTask() method, this method cant kill your Android app, it just means :

Finishes all activities in this task and removes it from the recent tasks list.

You could use the following code to implement this feature :

FinishAndRemoveTask();
Java.Lang.JavaSystem.Exit(0);// Terminate JVM

Upvotes: 1

Related Questions