Posted on

Android – How to close the app

https://stackoverflow.com/questions/6330200/how-to-quit-android-application-programmatically

https://stackoverflow.com/questions/22602365/closing-android-application-programmatically

Since API 16 you can use the finishAffinity method, which seems to be pretty close to closing all related activities by its name and Javadoc description:

this.finishAffinity();

Finish this activity as well as all activities immediately below it in the current task that have the same affinity. This is typically used when an application can be launched on to another task (such as from an ACTION_VIEW of a content type it understands) and the user has used the up navigation to switch out of the current task and into its own task. In this case, if the user has navigated down into any other activities of the second application, all of those should be removed from the original task as part of the task switch.
Note that this finish does not allow you to deliver results to the previous activity, and an exception will be thrown if you are trying to do so.

Since API 21 you can use a very similar command

finishAndRemoveTask();

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

or

public void close()
{
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
}
Posted on

Interview tasks

I had 10 Android interviews during the last two years, here’s the questions plus some lessons I’ve learned

Android Interview Questions

https://habrahabr.ru/company/itinvest/blog/339740/

www.interviewbit.com [https://www.interviewbit.com/]

http://e-maxx.ru/algo/ (pdf)

pdf

Google job interview (zip)

https://habrahabr.ru/company/spice/blog/346424/

https://habrahabr.ru/company/spice/blog/347056/ (Adobe questions)

https://habrahabr.ru/company/spice/blog/348122/ (Amazon)

https://habrahabr.ru/company/spice/blog/348746/ (Samsung)

https://habrahabr.ru/company/spice/blog/350788/ (DELL)

https://habrahabr.ru/company/spice/blog/352454/ (google)

https://habr.com/company/spice/blog/353952/ (Amazon)

https://habr.com/company/spice/blog/358064/

https://habr.com/company/spice/blog/358918/

https://habr.com/company/spice/blog/413571/

tasks from Uber (pdf)

programmers tasks https://tproger.ru/category/problems/

Android question (http://startandroid.ru/ru/blog/538-voprosy-i-zadachi-na-sobesedovanie-android-razrabotchika.html)