Hi,
it randomly happens that when i pick and image from gallery using the contentchooser the activity is destroyed. How i can prevent this?
I have tried to start a service in foreground when launching the contentchooser and stop the service on success but this does not works for me, it still happends.
Anyone has some working example please? i'm getting frustrated :€
"If you have a long running task and you don't want the OS to kill your process when there is no visible activity then you should call Service.StartForeground. Android will treat your application as if it is a visible application and will not kill it"
I call this service before executing the contentchooser but my activity still get killed time by time
B4X:
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
Dim nb As Notification
End Sub
Sub Service_Create
nb.Initialize
nb.Icon=""
nb.OnGoingEvent = False
nb.Vibrate=False
nb.Sound = False
nb.Notify(0)
Service.StartForeground(0, nb)
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub Service_Destroy
'Service.StopForeground(0)
End Sub
Contentchooser
B4X:
Sub btnUpload_Click
Dim q As Int
q= Msgbox2("Upload picture?","Choose","","Cancel", Null)
If q = DialogResponse.POSITIVE Then
StartService(busyService)
ImageChooser.show("image/*", "Choose image")
Else If q = DialogResponse.NEGATIVE Then
ToastMessageShow("Operation cancelled", True)
Else If q = DialogResponse.CANCEL Then
ToastMessageShow("Operation cancelled", True)
End If
End sub