언어 설정

Menu
Sites
Language
Keeping a web app running in the background

Hi,

Well i'm brand new to the Tizen app development world but slowly getting there.

I'm trying to create a gear S3 web App that connects to a bluetooth board (v2.0) and once bonded sends a 'ping' every few seconds to to tell an arduino board to unlock a door. If the pings stop, the door re-locks automatically.

 

The basic idea is that as long as i'm wearing my watch, if i walk up to a door it auto unlocks and when i walk away it re-locks itself.

The App works great - does everything as expected. Recorgnises and re-connects to the Bluetooth adapter automatically and starts pinging. recorgnises that its out of range and stops the pings. All goes well.

 

The problem is this - although the Web App is set to 'background enabled', after approx 15min or so it goes to sleep! The app unloads from memory (according to gear monitor app on phone) and does nothing. So far i've tried...

   tizen.power.request("CPU", "CPU_AWAKE"); ---> Doesn't do anything.

i've set a 'setInterval' function that pings every minute the function...

    tizen.application.launch(app.appInfo.id); 

This is an attempt to bring the app back to the foreground and keep working. anoyingly it wakes the screen too with the app on which i dont want to see, but again after 15min or so this stops working too!!

Nothing seems to keep the app awake, when running it uses 2-3% CPU according to the samsung gear monitor. I don't mind the additional power drain, i re-charge every evening.

 

Please can anybody help. I've been stuck at this for two weeks now and cannot find anyway to keep a background app alive and talking to the bluetooth devices.

Thanks,

Chris

 

Responses

5 댓글
Iqbal Hossain

Add this in config.xml

  <tizen:setting screen-orientation="portrait" context-menu="enable" background-support="enable" />
Chris Davies

Thanks,

The background support was already enabled but i added the above line just to be sure.

I've also added a timer on the arduino side of things which tells me the app goes to sleep after 10 minutes, despite the above commands and the bckground support enabled flag.

Are there any other suggestions as to how to keep the app alive? i've even added more 'Setintervals' in the javascript but nothing seems to stop it going to sleep after 10 minutes of background use.

 

Regards,

Chris

Chris Davies

Has anybody had any thoughts of this. There must be some way of keeping an app alive for longer than 10 minutes???

How does the fitness side of things operate, how it the heart rate polled on a regular basic. Surely there must be a simple solution to this, its driving me barmy! Why does the CPU_AWAKE just not do as its told!!

 

Iqbal Hossain

I know two ways

One is by enabling background support and another is by CPU_AWAKE. It seems you have tried the both ways.  So, i will suggest you to write a service app for communicating and working in background. Then you have to build both the apps together that is called Hybrid App in Tizen. 

Hello,

Did you solve this problem? I am also working on getting sensor data continuously from gear fit2 without sleep. It seems I can get heart rate monitor, but other sensors are not possible to extract since this gear fit2 kept sleeping. 

It seems native app can do with background running but I cannot find any example with web app doing background running. Do I have to do with hybrid app in this case? Anything helps. Please let me know.