Topic
1 reply Latest Post - ‏2011-07-17T07:06:25Z by SystemAdmin
SystemAdmin
SystemAdmin
110 Posts
ACCEPTED ANSWER

Pinned topic Android gadgets

‏2011-07-15T21:27:55Z |
Hi,
Is there a possibility to create Android gadgets using Worklight?
I tried from eclipse plugin and it creates me a normal Android application.
Thanks
  • SystemAdmin
    SystemAdmin
    110 Posts
    ACCEPTED ANSWER

    Re: Android gadgets

    ‏2011-07-17T07:06:25Z  in response to SystemAdmin
    Hi,

    Worklight currently does not support Android Widgets, however, this is a feature we are planning to support in a future version.
    Meanwhile, please find attached a sample Android widget added to a Worklight app. the file is available on Dropbox: http://dl.dropbox.com/u/3833898/widget.zip.

    Overview
    • The widget is exposed by the Worklight Starter app
    • The widget is written natively, using the Worklight Android Java SDK to retrieve data from the Worklight Server (similar to what the Worklight Starter app does)

    Here are the modifications that were done to the original Worklight Starter app:
    • com.worklightStarter.WorklightWidget – A widget which starts a background service that pulls information using the Worklight Android Java API and updates the widget.
    • com.worklightStarter.MyInvokeWLResponseListener – RSS Feed response listener, updates the screen with the response data.
    • res\\layout\\widget_message.xml + widget_word.xml – Widget layout configuration.
    • xml\\widget_word.xml – Widget definition
    • AndroidManifest.xml – add receiver and service tags (receiver is the widget definition. service – so we can start a background service).

    Note 1: To use the Worklight Android Java API within a widget, we needed to add a constructor for the WLClient object in the WLClient.java file, as listed below. We'll also make this code part of the next official Worklight release.
    
    
    
    public WLClient(Context context) 
    { Properties prop = 
    
    new Properties(); 
    
    try 
    { prop.load(context.getAssets().open(WLConfig.WL_CLIENT_PROPS_NAME)); 
    } 
    
    catch (IOException e) 
    { e.printStackTrace(); 
    } this.config = 
    
    new WLConfig(prop); this.authListener = 
    
    null; this.httpContext = 
    
    new BasicHttpContext(); 
    }
    


    Note 2: Don't forget to configure the app to point to your Worklight Server, where the Worklight Starter adapter is installed.
    I hope this addresses your needs.