Salve a tutti,
spero che almeno tra noi poveri Italiani qualcuno abbia risolto il mio problema.
In un Foreground Service intercetto il ConnectivityChanged (come phonevent). Funziona bene fino a che durante la notte il telefono va in sospensione profonda. Infatti se collegato al caricabatterie il problema non si presenta. E dire che ho un timer che ogni 10 minuti manda un GET a un sito.
Comunque tutto funziona, ma il Connectivitychange non riporta più nulla a. meno di non riavviare l'APP
Avete un'idea?
Quando il dispositivo è spento, l'applicazione farà una pausa e non funziona l'evento.
Mettete questo evento su un Modulo di Servizio e funzionerà
B4X:
Sub Process_Globals
Dim statoTelefono As PhoneEvents
End Sub
Sub Service_Create
Dim PhoneId As PhoneId
Dim PE As PhoneEvents
StatoTelefono.InitializeWithPhoneState("EventName",PhoneId)
End Sub
Sub Service_Start (StartingIntent As Intent)
StartServiceAt("", DateTime.Now + 10 * DateTime.TicksPerMinute, True) ' Chiamare il servizio ogni 10 minuti
' Scrivi qui la tua chiamata GET
End Sub
Sub EventName_ConnectivityChanged (NetworkType As String, State As String, Intent As Intent)
End Sub
Ciao Jesus,
this what I did till today. On some smartphone the event blocks till APP restart, even if it's on a service.
I wrote a small library to get the status on demand. I have published on the forum. Seems to have some issue on old HTC...
Questo è quanto ho fatto fino a oggi. Su alcuni smartphone l'evento si blocca fino alla ripartenza dell'APP anche se il codice è su un Service. Per risolvere ho scritto una libreria che ho pubblicato sul forum.
Your Italian is better than many Italians one, too!
Il tuo Italiano è migliore di quello di molti Italiani!
Ho un software che rileva la carica della batteria, ho fatto un servizio, e ho aggiunto questo e non mi riesce.
Forse in altri dispositivi si comportano diversamente, è successo a me in altre occasioni
B4X:
#Region Service Attributes
#StartCommandReturnValue: android.app.Service.START_STICKY
Ho un software che rileva la carica della batteria, ho fatto un servizio, e ho aggiunto questo e non mi riesce.
Forse in altri dispositivi si comportano diversamente, è successo a me in altre occasioni
B4X:
#Region Service Attributes
#StartCommandReturnValue: android.app.Service.START_STICKY