Results 1 to 8 of 8
  1.    #1  
    like the title says, i just want an app to completely run in the background as it simply subscribes to display events and reacts to the status of the display returned. is there an easier way to do this in 1.4.1 than creating a dashboard stage? i know brightness unlinked uses a workaround, but i cant deduce how thats done. any ideas?
  2. Tibfib's Avatar
    Posts
    345 Posts
    Global Posts
    347 Global Posts
    #2  
    Quote Originally Posted by srath16 View Post
    like the title says, i just want an app to completely run in the background as it simply subscribes to display events and reacts to the status of the display returned. is there an easier way to do this in 1.4.1 than creating a dashboard stage? i know brightness unlinked uses a workaround, but i cant deduce how thats done. any ideas?
    This is how I do it. It may not be the most efficient but it works.


    See Multi-Stage Applications - WebOS101 and set up your app to multi-stage (if it isn't already). Then add a case under launchparams.action:


    Code:
            
         case 'refreshData':
               /*This calls a global function that checks for new data. 
               I have the function set up to have a call-back function. 
               This call-back is in my app-assistant and will launch a dashboard if there is new data or so forth. */
                Refresh.refreshAll(this.handleRefresh.bind(this)); 
    
                Mojo.Log.info("Refreshing...");
                      
                this.key = "appRefresh"
                var params = {
    			"wakeup": true,
    			"key": this.key,
    			"uri": "palm://com.palm.applicationManager/open",
    			"params": '{"id":"com.appID","params":{"action": "refreshData"}}'
                };
                params["in"] = "00:05:00"; //this means check in 5 mins. there is also an "at" parameter.
    			
    		new Mojo.Service.Request('palm://com.palm.power/timeout', { 
    			method: "set",
    			parameters: params,
    			onSuccess:  this.handleOKResponse.bind(this), //make in app assistant
    			onFailure:  this.handleErrResponse.bind(this) //make in app assistant
    		});
             break;
    Let me know if you need me to explain more
  3.    #3  
    I do not have access to a computer at the moment, but I have a few questions about the script provided. Can I use the noWindow property in the sources.json as well? And if so, will the app continuously run in the background without being terminated by the GC?
  4. Tibfib's Avatar
    Posts
    345 Posts
    Global Posts
    347 Global Posts
    #4  
    Quote Originally Posted by srath16 View Post
    I do not have access to a computer at the moment, but I have a few questions about the script provided. Can I use the noWindow property in the sources.json as well? And if so, will the app continuously run in the background without being terminated by the GC?
    the nowindow property (in the appinfo.json) is required for multi-stage apps. You can NOT make an entirely headless app. Palm won't let you anymore. Your app has to have a card stage.

    I haven't done complete testing with the GC yet. I think the problem can be circumvented doing this.controller.serviceRequest instead of New Mojo.Service.Request.

    The problem with this method is it won't start until the app is launched. This is important to consider after reboots. If the timer gets missed because the phone was off, it won't keep going (I think. I don't think missed alarm requests are completed upon reboot). What you could do is make a daily alarm to start the refreshing. I have yet to implement that in my app but plan to do so.
  5. #5  
    Quote Originally Posted by Tibfib View Post
    the nowindow property (in the appinfo.json) is required for multi-stage apps. You can NOT make an entirely headless app. Palm won't let you anymore. Your app has to have a card stage.

    I haven't done complete testing with the GC yet. I think the problem can be circumvented doing this.controller.serviceRequest instead of New Mojo.Service.Request.

    The problem with this method is it won't start until the app is launched. This is important to consider after reboots. If the timer gets missed because the phone was off, it won't keep going (I think. I don't think missed alarm requests are completed upon reboot). What you could do is make a daily alarm to start the refreshing. I have yet to implement that in my app but plan to do so.
    Alarms can be set to be persistent after reboots. See the docs for how to do this.

    Apps can be headless; however if there are no visible stages they will be killed 60 seconds after being launched (for webOS 1.4.1.1 and later) or 15 seconds for webOS versions prior to 1.4.1.1.

    As far as the service request calls, I usually use this.controller.serviceRequest when in a scene. When I'm running code from the AppAssistant, I use "new Mojo.Service.Request" however I assign the result to a global variable (this.whatever). Requests have to be assigned a persistent reference or there's a chance they will be cut short by GC.
    Quick Post: The quick way to post messages and photos to Twitter & Facebook (video link)
    Music Player (Remix): The next generation music listening experience on webOS (video link)
    GeoStrings: Set location-based reminders and never forget another task (video link)

    Twitter: @Hedami
  6.    #6  
    I see. When I open jstop, I see multiple palm applications, as well as brightnessunlinked, which is expected. Howeve brightness unlinked works is how I want my app to work. I noticed that BU uses a loaded script on startup, could this method be used to run a background script instead of the entire app? Whatever method that is used for BU avoids the GC and still supports service calls. Thanks for all the help guys
  7. Tibfib's Avatar
    Posts
    345 Posts
    Global Posts
    347 Global Posts
    #7  
    Quote Originally Posted by srath16 View Post
    I see. When I open jstop, I see multiple palm applications, as well as brightnessunlinked, which is expected. Howeve brightness unlinked works is how I want my app to work. I noticed that BU uses a loaded script on startup, could this method be used to run a background script instead of the entire app? Whatever method that is used for BU avoids the GC and still supports service calls. Thanks for all the help guys
    I'm not sure how brightness unlinked does it. I'm pretty sure using that method would keep your app out of the catalog. Alarms are probably the best palm-sanctioned way to run an app in the background.
    Last edited by Tibfib; 05/15/2010 at 04:10 PM.
  8.    #8  
    I'm not exactly looking for palm sanctioned, this is just a pesonal project. Any help is always apprecaited

Posting Permissions