app SmartWatch

78 views
Skip to first unread message

yuri melo

unread,
Jul 13, 2015, 11:15:31 AM7/13/15
to androi...@googlegroups.com
Is possible create a smartwatch app with droidscript ?
somebody have a example????????? tks!!!!!!!!!!! 

Gloglas´s Studio

unread,
Jul 13, 2015, 3:13:14 PM7/13/15
to androi...@googlegroups.com
Hi,
Try to search in forum and wiki ;).
Here is example that Dave Smart posted on forum.
( original topic: https://groups.google.com/forum/m/#!topic/androidscript/1DM9M1HRZi8 )
//This is an example of a Sony Smartwatch2 service App. 
//You must name the app with a prefix of "SWS-" for it  
//to be detected by the watch. eg. "SWS-MyApp"  
//(Note: This app can only be launched from the Watch, it
//has no interface for the phone/tablet)

//Called when application is started.
function OnStart()
{
   
//Create SmartWatch object and set callbacks.
    watch
= app.CreateSmartWatch( "Sony" );
    watch
.SetOnShow( watch_OnShow );
    watch
.SetOnHide( watch_OnHide );
    watch
.SetOnTouch( watch_OnTouch );
    watch
.SetOnSwipe( watch_OnSwipe );
    watch
.SetOnStop( watch_OnStop );
    watch
.SetOnMenu( watch_OnMenu );
    watch
.SetOnBack( watch_OnBack );
     
   
//Show a quick message at startup.
    watch
.ShowMessage( "Hello" );
     
   
//Create a watch layout.
    lay
= watch.CreateLayout( "Linear", "fillxy" );
     
   
//Add some text.
    txt
= watch.CreateText( "ABC", 1.0, 0.3, "" );
    txt
.SetBackColor( "#ff006666" );
    txt
.SetMargins( 0,0.1,0,0 );
    txt
.SetTextSize( 8 );
    txt
.SetTextColor( "#ffffffff" );
    lay
.AddChild( txt );
     
   
//Add an image.
    img
= watch.CreateImage( "/Sys/Img/Icon.png", 0.3 );
    lay
.AddChild( img );
     
   
//Add and display layout.
    watch
.AddLayout( lay );
    watch
.ShowLayout();
}

//Called when SmartWatch app is shown.
function watch_OnShow()
{
    app
.ShowPopup( "OnShow" );
     
   
//Show the layout.
    watch
.ShowLayout();
}

//Called when SmartWatch app is hidden.
function watch_OnHide()
{
   app
.ShowPopup( "OnHide" );
}

//Called when SmartWatch app is stopped.
function watch_OnStop()
{
    app
.ShowPopup( "OnStop" );
}

//Handle SmartWatch touch event.
function watch_OnTouch( dir, x, y )
{
    app
.ShowPopup( "OnTouch dir="+dir+" x="+x+" y="+y );
}

//Handle SmartWatch swipe event.
function watch_OnSwipe( dir )
{
    app
.ShowPopup( "OnSwipe dir="+dir );
}

//Called when SmartWatch menu button is touched.
function watch_OnMenu()
{
   
//Show an image on screen.
    app
.ShowPopup("watch_OnMenu");
}

//Called when SmartWatch back button is touched.
function watch_OnBack()
{
   
//Stop the watch app.
    watch
.StopApp();
}


Reply all
Reply to author
Forward
0 new messages