Android Question Clear back history

ambg

Member
Licensed User
is there any way to completely clean the history open activities and the back key to close the application?

For example

3 Activities (Main, 1,2)

Start Main Activity

In Main
StartActivity(1)

In 1
StartActvity(2)

In 2
Activity.Finish
StartActivity(Main)

If the user then click back key go back to 1 and i want that close the application.
 

sorex

Expert
Licensed User
you can intercept the back event and do your own thing there.
 

ambg

Member
Licensed User
If you are targeting Android 4.1 (API level 16) then you can use this code to close all activities:
B4X:
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethod("finishAffinity", Null)
Works fine. Thanks
 
Top