extend the Android client functionalities [since 4.1]

The OberonClient class contains all basic functionalities to develop a simple Android app; when you develop your application, you will probably need to extend the client with a specialized functions. For a web-application, you can create additional JSP pages or servlet linked by command urls, and add/edit css styles or javascript scripts to implement different behaviours or set the look and feel.
For a mobile and desktop application you can extend the basic class OberonClient; in particular, you should:

- manage the page urls defined inside the commands by adding redirect conditions to the handleRequest method.
- write the "handle" method to perform the new function(s)
- operate modifications to the Android control's styles to set the graphical aspect.
- use a different package name for each application otherwise you will not be able to commit it to the Google Play store

Redirecting custom URLs

As said before, the most important method of a mobile client class is:

handleRequest(ApplicationRequest request)

This method redirects the request to another specific method according to the requested page (or URL) declared inside the ApplicationRequest itself. It means that for each web URL associated with menu commands there should be a method that represents the equivalent web-page in Android format. The handleRequest method, defined inside the OberonClient class, redirects basic URLs to predefined handle methods. You can override this method, but differently respect to the SWT custom client, the choice is delayed to allow the UI thread to show the "Loading..." message indicator. You have to copy all possible choices and add your pages / functions at the end of the "if-"else" sequence:

NOTE: In some cases, you want also change the behaviour of some basic operations (for example to create a custom home page). These modifications can be performed by defining custom methods, named as the basic method in a manner (for example doHome) to "override" the predefined actions.

The following example show how to implement a custom basic function:

mypage.jsp -> doMyPage

public void doMyPage(ApplicationRequest request) {
   try {

  // Get the session if you need it
ApplicationSession session = (ApplicationSession) request.getSession();

// Define title and subtitle for the menu bar
String sTitle = "My Page Title";
String sSubTitle = "My Page SubTitle";
// Creates the page container (includes the menu bar with title and subtitle)

LinearLayout globalpanel = createPagePanel(this, sTitle, sSubTitle, !bCreateNew, request);
if (globalpanel!=null) {

// Define the Android panel
panel = new ScrollView(globalpanel.getContext());

........... Add the content the the ScrollView panel ...........

.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout          .LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
// Add the page container to the application window (tab widget or alert dialog)


   } catch (Exception ex) { log(ex.getMessage()); }

Changing the look and feel

Finally, you can operate modifications to the Android control's styles to set the graphical aspect by replacing the basic method setCSSStyles. In particular, inside this method you can define new styles or apply changes to default styles; the following example shows how to write the code:

Pre-defined styles are:

the horizontal banner where the title and subtitle are placed
the title text
  CSS_SubTitle the sub-title text
the horizontal banner where the object's contextual buttons are placed
the form style
the style of form's cells
field (description) label
generic text
section separator banner
text field style
textarea field style
combo field style
multi-selection combo field style
checkbox / radio button style
web link style
image and embedded object style
static text
button bar style
form - buttons

NOTE: Images used to customize the look and feel must be placed inside the "res/drawable" folder of Eclipse project.

<< create mobile (Android) clients  
© 2008-2015 MS Enterprise Solutions | Website Templates by IceTemplates.com
Please Read: Privacy Policy and Terms of Use