nativescript vue back button handler
if (application.android) { application.android.on(application.AndroidApplication.activityBackPressedEvent, function() { // commit or dispatch stop player ); }
Here is what the above code is Doing:
1. We’re using the application.android.on() method to listen for the activityBackPressedEvent.
2. When the event is triggered, we’re using the application.android.foregroundActivity property to get a reference to the current activity.
3. We’re using the activity.moveTaskToBack() method to move the app to the background.
Note: If you want to move the app to the background without triggering the activityBackPressedEvent, you can use the application.android.foregroundActivity.moveTaskToBack() method.