permanently close an app

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hi,
how can I close permanently a running up, by tapping on the button back of the tablet?
Thk :confused:
 

qsrtech

Active Member
Licensed User
Longtime User
I think you can use activity.fininsh. maybe use it in the activity_keypress event. check for keycode=keycodes.keycode_back? Return true. That's what I use and it seems to work. Maybe try it in the Pause event?

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
   Select Case KeyCode
      Case KeyCodes.KEYCODE_BACK
         'sould we confirm action??
         Activity.Finish
         Return True
   End Select
End Sub
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
I think you can use activity.fininsh. maybe use it in the activity_keypress event. check for keycode=keycodes.keycode_back? Return true. That's what I use and it seems to work. Maybe try it in the Pause event?

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
   Select Case KeyCode
      Case KeyCodes.KEYCODE_BACK
         'sould we confirm action??
         Activity.Finish
         Return True
   End Select
End Sub

I'll try
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
I think you can use activity.fininsh. maybe use it in the activity_keypress event. check for keycode=keycodes.keycode_back? Return true. That's what I use and it seems to work. Maybe try it in the Pause event?

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
   Select Case KeyCode
      Case KeyCodes.KEYCODE_BACK
         'sould we confirm action??
         Activity.Finish
         Return True
   End Select
End Sub

Hi qsrtech,
I tried, but the app remains in memory and I find among recent applications.
I don't want to find it.
Thanks
 
Upvote 0

qsrtech

Active Member
Licensed User
Longtime User
I'm not sure if you can completely remove it from "memory". I know when I exit an app using the task manager it still shows up in the task list.
 
Upvote 0

gregwa

Member
Licensed User
Longtime User
From the Beginner's Guide...

Most applications should not use ExitApplication but prefer Activity.Finish which lets the OS
decide when the process is killed.
You should use it only if you really need to fully kill the process.

By using Activity.Finish, Android gets rid of the app when it needs more memory.
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hi gregwa,
thank you for your reply.
I used ExitApplication, but the app still remain in "memory" into the task manager. :(
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Calling ExitApplication will immediately kill the process. If you have a running process then Android will try to rerun your app (as if it has crashed). Monitor the unfiltered logs.

Hi Erel,
so it is possibile to not rerun the app? :(
 
Upvote 0

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
I must say that all of this is not really needed and in almost all cases will only cause problems. You should let the OS handle the processes.


Yes. By closing all activities and services.

thanks to all :sign0087:
 
Upvote 0
Top