Start tizen app at start up

巧了我就是萌 提交于 2019-12-11 20:36:00

问题


I have an app in Tizen, and I would like to run it at the watch's boot up. Here is how my app.js looks like:

$(document).ready(function() {
    document.addEventListener('tizenhwkey', function(e) {
        if(e.keyName == "back") {
            tizen.application.getCurrentApplication().exit();
        }
    });
// The rest of the program
}

Now, I can see that a Service Application can be executed at the start up, and here explains what are the necessary steps to build a Service Application. However, I was not able to relate these topics to my application. If I want to have my application started at the boot up, do I need to change it to a Service Application? What are the changes I need to do?


回答1:


Yes, you can. If You understood the main point about web service app tht it will not hv an UI.

To convert web app to web service app, you need to append your config.xml file with below code

 <widget>
      <tizen:service id="websvcapp0.service1" auto-restart="true" on-boot="false">
      <tizen:content src="service/service1.js" />
      <tizen:name>WebServiceApplication1</tizen:name>
      <tizen:icon src="icon1.png" />
      <tizen:description>WebServiceApplication1</tizen:description>
   </tizen:service>
 </widget>

Final look of config.xml will be like this

<?xml version="1.0"encoding="TF-8">
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen=http://tizen.org/ns/widgets
        id="http://yourdomain/WebServiceApplication" version="1.0.0" viewmodes="maximized">
   <tizen:application id="websvcapp0.WebServiceApplication" package="websvcapp0" required_version="2.3" />
   <content src="index.html" />
   <feature name="http://tizen.org/feature/screen.size.all" />
   <icon src="icon.png" />
   <name>WebServiceApplication</name>
   <tizen:service id="websvcapp0.service1" auto-restart="true" on-boot="false">
      <tizen:content src="service/service1.js" />
      <tizen:name>WebServiceApplication1</tizen:name>
      <tizen:icon src="icon1.png" />
      <tizen:description>WebServiceApplication1</tizen:description>
   </tizen:service>
</widget>

And add following privilege

  <tizen:feature name="http://tizen.org/feature/web.service"/>

This link provides complete method to be followed to create a web service application.

  • Creating a service app
  • Packaging
  • Launching
  • Terminating

https://developer.tizen.org/dev-guide/wearable/2.3.0/org.tizen.wearable.web.appprogramming/html/tutorials/service_tutorial/service_app_tutorial.htm




回答2:


For older versions of Tizen (web) I found a very, very dirty workaround (but what can you do, if basic functionality isn't available?).

You can make an alarm (basically a scheduled app-start) and set it up to start your app every 10 minutes or so. Either you have your app run in the background all the time (by overriding the "close app"-gesture and enabling run-in-background) and just before that alarm would fire (9 mins 55 seconds or so), you'd remove that alarm and reset it to 10 minutes. That way, your App will almost always run and it will be started at boot. But if you close it forcefully (with the app manager), it might take 10 minutes until it's running again.

Also, you might not want your app to pop open 10 minutes after you forcefully closed it, so you can read out the start parameters with

tizen.application.getCurrentApplication().getRequestedAppControl().appControl.data 

and hide the app immediately (100ms) after launching it. The app will pop up and immediately close again. I couldn't keep that from happening, but it's a workaround that works somewhat acceptably.



来源:https://stackoverflow.com/questions/31483822/start-tizen-app-at-start-up

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!