Results 1 to 6 of 6
  1.    #1  
    So I'm done with the core of my app. I need to add a headless stage that runs in the background and fires up every 15 minutes. A great example of this is Switcharoo, where every 30 minutes (or however often the user decides) the headless portion fires up and switches your background.

    What I do know...
    I have to setup the AppController to manage the stages and I have to use the alarm mechanism to wake the background stage so that it can do it's thing.

    What I don't have...
    A SOLID code example of how to do this. Maybe I'm just not looking in the right places. Can someone either point me to a link that has one or post one here? It would be VERY MUCH appreciated!!!
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  2. #2  
    Pretty sure you need the Timeout service "palm://com.palm.power/timeout" for that, you can tell it to run your app in X minutes and give it params etc. if it should still do it while in stand by or only when active etc.
    My Palm History (in order): IIIe SE, m130, Tungsten|T, m505, Tungsten|T3, Zire 71, m505 (owned two different ones), Zire 72, Tungsten|C, T|X, Treo 650.
    After that I got a Apple iPhone 3G, Palm Pre (GSM), Google Nexus One.
  3.    #3  
    Got it: Alarms - webOSdev - Palm
    (NOTE: Palm must have updated this with code examples, they weren't there a few weeks ago.)

    On to finding more info on the headless part...
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  4.    #4  
    I've found a few examples and have the following code...

    app-assistant.jsjsjs
    Code:
    function AppAssistant (appController) {}
    
    // -> CODE SETTING GLOBAL NAMESPACE VARIABLES (STRIPPED FOR THIS EXAMPLE)
    // -> CALLBACK FUNCTIONS REQUIRED FROM SETTING GLOBALS (STRIPPED FOR THIS EXAMPLE)
    
    
    // handleLaunch function
    AppAssistant.prototype.handleLaunch = function (launchParams)
    {
    	// SET STAGE CONTROLLER AND PROXY VARIABLES
    
    		var stageProxy          = this.controller.getStageProxy('mainStage');
    		var cardStageController = this.controller.getStageController('mainStage');
    
    	// SEE IF STAGE PROXY EXISTS
    
    		if (stageProxy)
    		{
    			// SEE IF STAGE EXISTS
    			// IF SO, BRING WINDOW TO FOCUS
    			// IF NOT (ONLY PROXY EXISTS), PUSH FIRST SCENE
    
    				 if (cardStageController) {cardStageController.window.focus();}
    				 else
    				 {
    					var stageArguments = {name: 'mainStage', lightweight: true};
    					var pushHomeScene  = function(stageController) {stageController.pushScene('home');};
    
    					this.controller.createStageWithCallback(stageArguments, pushHomeScene, 'card');
    				 }
    		}
    
    
    }
    
    // handleCommand function
    AppAssistant.prototype.handleCommand = function(event)
    {
    	if (event.type == Mojo.Event.command)
    	{
    		switch(event.command)
    		{
    			case 'do-aboutMoJack':
    
    				var cardStageController = this.controller.getStageController('mainStage');
    				var currentScene        = cardStageController.activeScene();
    
    				currentScene.showAlertDialog
    				({
    					onChoose: function(value) {},
    					   title: 'MoJack - V1.0.0',
    					 message: 'Copyright 2009, MoJack LLC http://www.mojackapp.com',
    					 choices: [{label: 'OK', value: ''}]
    				});
    
    			break;
    		}
    	}
    }
    sources.json
    Code:
    [
        {"source": "app/assistants/app-assistant.jsjsjs&$quot$;},
        {&$quot$;$source$&$quot$;: &$quot$;$app$/$assistants$/$stage$-$assistant$.$js$&$quot$;},
        {
            &$quot$;$scenes$&$quot$;: &$quot$;$home$&$quot$;,
            &$quot$;$source$&$quot$;: &$quot$;$app$/$assistants$/$home$-$assistant$.$js$&$quot$;
        },
        {
            &$quot$;$scenes$&$quot$;: &$quot$;$createAccount$&$quot$;,
            &$quot$;$source$&$quot$;: &$quot$;$app$/$assistants$/$createAccount$-$assistant$.$js$&$quot$;
        },
        {
            &$quot$;$scenes$&$quot$;: &$quot$;$login$&$quot$;,
            &$quot$;$source$&$quot$;: &$quot$;$app$/$assistants$/$login$-$assistant$.$js$&$quot$;
        },
        {
            &$quot$;$scenes$&$quot$;: &$quot$;$addDevice$&$quot$;,
            &$quot$;$source$&$quot$;: &$quot$;$app$/$assistants$/$addDevice$-$assistant$.$js$&$quot$;
        },
        {
            &$quot$;$scenes$&$quot$;: &$quot$;$swapDevice$&$quot$;,
            &$quot$;$source$&$quot$;: &$quot$;$app$/$assistants$/$swapDevice$-$assistant$.$js$&$quot$;
        },
        {
            &$quot$;$scenes$&$quot$;: &$quot$;$swapDeviceList$&$quot$;,
            &$quot$;$source$&$quot$;: &$quot$;$app$/$assistants$/$swapDeviceList$-$assistant$.$js$&$quot$;
        }
    ]
    My app launches a card, but it's blank. I can't quite figure out why. I've stripped the code down in app-assistant.jsjsjs $down$ $to$ $bare$ $minimum$ $needed$ $and$ $I$ $still$ $can$'$t$ $get$ $my$ &$quot$;$home$&$quot$; $scene$ $to$ $launch$. $Is$ $there$ $something$ $that$ $has$ $to$ $be$ $added$ $to$ $stage$-$assistant$.$js$, $or$ $should$ $it$ $be$ $completely$ $blank$? $I$ $followed$ $the$ $instructions$ $on$ $page$ $247$ $of$ $the$ $Palm$ $webOS$ $book$ $which$ $stated$ $the$ $code$ $from$ $stage$-$assistant$.$js$ $should$ $be$ $moved$ $to$ $app$-$assistant$.$js$ $and$ $edited$ $to$ $reflect$ $the$ $change$. $The$ $code$ $examples$ $in$ $the$ $end$ $of$ $the$ $book$ $don$'$t$ $include$ $stage$-$assistant$.$js$, $so$ $I$ $assumed$ $it$ $was$ $blank$.

    Any ideas???

    NOTE: Everything was working in the app before trying to add an app assistant. Right now I'm just trying to get a single stage app assistant working, then add the second stage.
    Last edited by Laxidasical; 11/16/2009 at 04:38 AM. Reason: Typo
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  5.    #5  
    I figured out what I was doing wrong. The code example I found wasn't indented very well. I went through again line by line. My handleLaunch function in app-assistant should have been...

    Code:
    AppAssistant.prototype.handleLaunch = function (launchParams)
    {
    	// SET STAGE CONTROLLER AND PROXY VARIABLES
    
    		var stageProxy          = this.controller.getStageProxy('stage');
    		var cardStageController = this.controller.getStageController('stage');
    
    	// SEE IF STAGE PROXY EXISTS
    
    		if (stageProxy)
    		{
    			// IF SO, BRING WINDOW TO FOCUS
    			// ELSE, DO NOTHING
    
    				 if (cardStageController) {cardStageController.window.focus();}
    		}
    		else
    		{
    			// SET STAGE ARGUMENTS
    			// SET FUNCTION THAT PUSHES THE HOIME SCENE
    
    				var stageArguments = {name: 'stage', lightweight: true};
    				var pushHomeScene  = function(cardStageController) {cardStageController.pushScene('home');};
    
    			// CALL MAIN STAGE AND PUSH FIRST SCENE
    
    				this.controller.createStageWithCallback(stageArguments, pushHomeScene, 'stage');
    		}
    
    }
    My app assistant now launches the main scene correctly. I have one other problem. For some reason the code that deactivated activity button spinners doesn't work. For example, suppose a button's id is "login". Before I would use...

    Code:
    login.mojo.deactivate();
    Anyone know what to use in place of this?
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  6.    #6  
    In case anyone else runs into this, I should have been using...

    Code:
    this.controller.get('login')mojo.deactivate();
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL

Posting Permissions