I end my apps with
Activity.Finish
ExitApplication
SetApplicationAttribute(android:clearTaskOnLaunch, "true")
I only use the main activity
If you have service modules you can use stopservice(name)
I am trying to understand why have multiple Activities - I just use panels and make them visible or not visible as required or zoom them down to .setlayout(0,0,1,1)
I only use the main activity
If you have service modules you can use stopservice(name)
I am trying to understand why have multiple Activities - I just use panels and make them visible or not visible as required or zoom them down to .setlayout(0,0,1,1)
Thanks KZero, but the manifest line didn't change it..
If all activities are finished then the app will start from main next time.. but the question is how to finish all the activities?
'code by JakeBullet70
Sub RestartApp
Dim R, R2 As Reflector
R.Target = R.GetActivity
R.Target = R.RunMethod("getApplicationContext")
R2.Target = R.RunMethod("getPackageManager")
Dim I As Intent
I = R2.RunMethod2("getLaunchIntentForPackage", R.RunMethod("getPackageName"), "java.lang.String" )
R.Target = I
R.RunMethod2("addFlags", 67108864, "java.lang.int")
StartActivity(I)
End Sub
Thanks KZero for your efforts..
(Activity_Resume ) of each activity? I have 5 activities in my project.
Also I don't want to restart the app. but when I restart it (anytime later) must restart from Main
Dim aExit as boolean
CodeModule.aExit=True
if CodeModule.aExit=True then
CodeModule.RestartApp
Return
End if
B4X:if CodeModule.aExit=True then CodeModule.RestartApp Return
Sorry, will this restart the app if aExit is true? but I don't want to restart the app.. (if I correctly understood your code).
Sub btnExit
CodeModule.aExit=True
Activity.Finish
End sib
'put it in all Activties
Sub Activity_Resume
if CodeModule.aExit=True then
CodeModule.RestartApp
Return
End if
end sub
End if
one more question: Where will this aExit variable live? will it still be alive after the activity is killed? or should I store it somewhere inB4X:Sub btnExit CodeModule.aExit=True Activity.Finish End sib
text file or SQLite database
it will be alive if the process still cached in memory, and if not the application will start normally because its already finished and its memory cleared
don't worry about itWell, I can pray for the process to live long, but you can't guarantee because on exit you only finished one activity, not all.. and your code depends on the life of the aExit variable.