Hi,
here is what I ended up doing, trying to figure it all out with Martin..
It isn't pretty but it works.
First you define the terminal-command sub, which uses Stringbuilder. This sub is your vehicle to issue what I call
terminal commands =
Sub terminalcommando(commando As String)
Dim Command, Runner As String
Dim StdOut, StdErr As StringBuilder
Dim Result As Int
Runner = File.Combine(File.DirInternalCache, "runner")
Command = File.Combine(File.DirInternalCache, "command")
File.WriteString(File.DirInternalCache, "runner", "su < " & Command)
File.WriteString(File.DirInternalCache, "command", commando & CRLF & "exit") 'Any commands via crlf, and exit at end
StdOut.Initialize
StdErr.Initialize
Result = ph.Shell("sh", Array As String(Runner), StdOut, StdErr)
End Sub
Then you do the killing where appropriate =
terminalcommando("busybox killall uk.co.aifactory.solitairefree")
Where
uk.co.aifactory.solitairefree is the package name of the app you want to kill (in this case Solitaire...)
This kill however kills only the current
ACTIVITY and is similar to the
BACK button of Android so in case you have more activities stacked, count the max possible stacked activities for the app and issue the above command this amount of times.
I do this with a simple timer/wait cycle after each kill command. In my case, a timer of 250ms ( JustDelay.Initialize("JustDelay", 250) )
was enough and I issue this command 3 times =
terminalcommando("busybox killall uk.co.aifactory.solitairefree")
waitXseconds
Do While Justwaiting
DoEvents
Loop
terminalcommando("busybox killall uk.co.aifactory.solitairefree")
waitXseconds
Do While Justwaiting
DoEvents
Loop
terminalcommando("busybox killall uk.co.aifactory.solitairefree")
waitXseconds
Do While Justwaiting
DoEvents
Loop
Of course, you need to define these =
Sub waitXseconds
JustDelay.Enabled = True
Justwaiting = True
End Sub
Sub JustDelay_tick
JustDelay.Enabled = False
Justwaiting = False
End Sub
That should do it.
Eric