Charlie-Blake
Charlie-Blake

Reputation: 11050

How to force close an app

When my app crashes, it loads again in a random activity instead of being force closed.

When I call android.os.Process.killProcess(android.os.Process.myPid()) it follows that behaviour too.

I just want my app to force close if needed and let the user send me their reports.

What should I do to avoid that behaviour?

Upvotes: 0

Views: 155

Answers (1)

Kuitsi
Kuitsi

Reputation: 1675

Are you sure it loads some random activity? Usually it loads the next activity on top of your app's activity stack.

from https://stackoverflow.com/a/7240460/262462:

  1. start first activity (either splash screen, or whatever activity is currently at the bottom of the activity stack) with FLAG_ACTIVITY_CLEAR_TOP (which will quit all the other activities started after it, which means - all of them). Just make to have this activity in the activity stack (not finish it for some reason in advance).
  2. call finish() on this activity

Upvotes: 1

Related Questions