PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WM] - App (APK) gets suspended...
[WM] - App (APK) gets suspended...
Iniciado por guest, 29,ago. 2016 16:14 - 5 respuestas
Publicado el 29,agosto 2016 - 16:14
Hello,

I a mobile app (APK) that I have developed.

I am using a back ground thread that will fetch data from remote server using web services and save the data locally.

But this process of fetching of data gets suspended if the phone screen is locked.

Why this happens?

How to prevent the thread from getting suspended even when the phone screen is shut down or the phone is locked?

TIA

Yogi Yang
Publicado el 29,agosto 2016 - 16:17
Hi Yogi,

This is expected behavior from Android. You need special permissions to do that.

Look at this: http://stackoverflow.com/questions/5345344/app-seems-to-stop-working-when-the-screen-goes-to-sleep

Best regards,
Alexandre Leclerc
Publicado el 29,agosto 2016 - 16:37
Hello Alex,

Thanks for the link. But how to implement this in WM?

TIA

Yogi Yang
Publicado el 29,agosto 2016 - 16:49
Hello Yogi,

I never needed that in the past, but... Check the WiFiActivate() function in WM. If you se this function it will automatically add this permission and it will also allow you to have feedback on the Wifi status. Maybe just using this option, because you want wifi feedback, will just do what you want.

Otherwise, send a small call to the free technical support on how this can be implemented easily. (I guess that simply adding the WAKE_LOCK permission to your android project will not be sufficient (??). You can simply try that option very quickly when you compile your APK. There is a screen to add permissions.)

Best regards,
Alexandre Leclerc
Publicado el 29,agosto 2016 - 16:53
Hi Yogi,

I forgot to mention that in WM you can add some java code directly. So you could call the required functions quite easily. Just do not forget to add the permission when you build your apk.

http://doc.windev.com/en-US/…

Kind regards,
Alexandre Leclerc
Publicado el 29,agosto 2016 - 16:58
Hi. The normal android threads are paused when the app go to second plane.

Do you have tried using a Persistent Thread? It will stay running with app in second plane or sleeping.

Rubén