Private Z
Private Z

Reputation: 11

React Native: BackHandler.exitApp() can't kill the app's process

When i see the native code.

BackHandler.exitApp() will invoke android's onBackPressed()

Why not invoke System.exit(0) to exit the app and kill process?

Upvotes: 1

Views: 3772

Answers (2)

Yossi
Yossi

Reputation: 6027

You may use react-native-exit-app,
and replace BackHandler.exitApp() with:

import RNExitApp from 'react-native-exit-app'; ... RNExitApp.exitApp(); ...

Upvotes: 1

Ajay S
Ajay S

Reputation: 48602

Why not invoke System.exit(0) to exit the app and kill process?

System.exit(0) is a bad approach to kill your application process. Android manage it in a awesome style. This made them to call onBackPressed()

Upvotes: 0

Related Questions