Lab 3: Using Worklight Server and Environment Optimization Lab Exercise

Similar documents
Lab 1: Getting Started with IBM Worklight Lab Exercise

Lab 2 Examine More Development Features in IBM Worklight

IBM Worklight V5.0.6 Getting Started

Lab Android Development Environment

Lab 1: Getting Started With Android Programming

Installing and configuring an Android device emulator. EntwicklerCamp 2012

Ionic Tutorial. For Cross Platform Mobile Software Development

Programming Concepts and Skills. Creating an Android Project

IBM BlueMix Workshop. Lab D Build Android Application using Mobile Cloud Boiler Plate

Tutorial on Basic Android Setup

XML Tutorial. NOTE: This course is for basic concepts of XML in line with our existing Android Studio project.

Mobile Programming Lecture 1. Getting Started

Exposing CICS Transactions to WLE

Getting Started with Android Development Zebra Android Link-OS SDK Android Studio

IBM Software. IBM Forms V8.0. Forms Experience Builder - Portal Integration. Lab Exercise

Choose OS and click on it

Getting started with Convertigo Mobilizer

Android Development Tools = Eclipse + ADT + SDK

Enterprise Caching in a Mobile Environment IBM Redbooks Solution Guide

BlackBerry Developer Global Tour. Android. Table of Contents

IBM WebSphere Java Batch Lab

Version 1.0 Last updated: August 11, 2017 Author: Albert Wang & Mike Hull

Composer Guide for JavaScript Development

The Discussion of Cross-platform Mobile Application Development Based on Phone Gap Method Limei Cui

IBM Maximo Anywhere Version 7 Release 6. Planning, installation, and deployment IBM

Tivoli Common Reporting V2.x. Training on Security Permissions

Oracle Utilities Customer Self Service

IBM i Version 7.2. Connecting to your system Connecting to Your system with IBM Navigator for i IBM

Minds-on: Android. Session 1

IBM VisualAge for Java,Version3.5. External Version Control

Tutorial: Android Object API Application Development. Sybase Unwired Platform 2.2 SP03

SafeWebApp Android QuickStart

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

Step 1 Turn on the device and log in with the password, PIN, or other passcode, if necessary.

Sterling Selling and Fulfillment Suite Developer Toolkit FAQs

Incident Response Platform Integrations BigFix Function V1.1.0 Release Date: October 2018

Configuring the Android Manifest File

IBM Atlas Policy Distribution Administrators Guide: IER Connector. for IBM Atlas Suite v6

Oracle Utilities Customer Self Service

Software Architecture Documentation for the JRC MYGEOSS app for Invasive Species project

Extended Search Administration

Web-enable a 5250 application with the IBM WebFacing Tool

IBM emessage Version 9 Release 1 February 13, User's Guide

!!! !!!!!!!!!!! Help Documentation. Copyright V1.7. Copyright 2014, FormConnections, Inc. All rights reserved.

IBM Maximo Anywhere Version 7 Release 6. Planning, installation, and deployment IBM

ECOM 5341 Mobile Computing(Android) Eng.Ruba A. Salamah

In this lab, you will build and execute a simple message flow. A message flow is like a program but is developed using a visual paradigm.

WebSphere Puts Business In Motion. Put People In Motion With Mobile Apps

HTML5 Applications Made Easy on Tizen IVI. Brian Jones / Jimmy Huang

IBM Monitoring Agent for Citrix Virtual Desktop Infrastructure 7.2 FP3. User's Guide IBM SC

Building a Simple Workflow Application for the Sybase Unwired Server [Part 3]

Pro Android 2. Sayed Y. Hashimi Satya Komatineni Dave Mac Lean. Apress

Android Programming Lecture 2 9/7/2011

Setting Up KidiConnect : Unlock KidiConnect

CA Gen. Gen Studio Overview Guide. Release 8.5. Third Edition

Building Hybrid and Mixed Model. Mobile Applications Lab

Contents. Anaplan Connector for MuleSoft

(Refer Slide Time: 1:12)

WebSphere. Clips and Tacks: Getting started with the IBM BPM suite of products

Basic Android Setup for Machine Vision Fall 2015

Enterprise Generation Language (EGL) for IBM i operating system Create a web application using EGL and the Data Access Application Wizard

Client Installation and User's Guide

Workbench User's Guide

Getting started with Tabris.js Tutorial Ebook

IBM Workplace Client Technology API Toolkit

BlueMix Hands-On Workshop

Your password is: firstpw

What s new in IBM Operational Decision Manager 8.9 Standard Edition

Incident Response Platform. IBM BIGFIX INTEGRATION GUIDE v1.0

Client Installation and User's Guide

Tivoli Common Reporting V Cognos report in a Tivoli Integrated Portal dashboard

Hands-on Lab Session 9011 Working with Node.js Apps in IBM Bluemix. Pam Geiger, Bluemix Enablement

Getting Started making DLAs to create IDML Discovery Books using Tivoli Directory Integrator. Written using TDI 7.1 FP1 Document version 1.

Installation Instructions

IBM Mobile Portal Accelerator Enablement

COURSE OUTLINE MOC 20480: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Android Application Development. By : Shibaji Debnath

Mend for Eclipse quick start guide local analysis

2015 Beta 2 Tutorials

Innovate 2013 Automated Mobile Testing

Lab 3. On-Premises Deployments (Optional)

Mobile OS. Symbian. BlackBerry. ios. Window mobile. Android

PROCE55 Mobile: Web API App. Web API.

Rule Modeling Case Study Generic Diabetic Monitoring. Mike Parish

Tutorial on OpenCV for Android Setup

AD406: What s New in Digital Experience Development with IBM Web Experience Factory

Virto SharePoint Forms Designer for Office 365. Installation and User Guide

Android Online Training

IBM Operational Decision Manager Version 8 Release 5. Configuring Operational Decision Manager on WebLogic

Exercise 1. Bluemix and the Cloud Foundry command-line interface (CLI)

IBM Workplace Collaboration Services API Toolkit

AppDev StudioTM 3.2 SAS. Migration Guide

Hands-On Lab. Authoring and Running Automated GUI Tests using Microsoft Test Manager 2012 and froglogic Squish. Lab version: 1.0.5

BCA 6. Question Bank

Introduction to Worklight Integration IBM Corporation

Paraben s Photo Backup Stick V2.1. User Manual

BlueMix Hands-On Workshop Lab A - Building and Deploying BlueMix Applications

14111: Building an Enterprise Mobile Application. Lab Exercise

Aware IM Version 8.2 Aware IM for Mobile Devices

Convert Your JavaScript Buttons for Lightning Experience

Transcription:

Lab 3: Using Worklight Server and Environment Optimization Lab Exercise

Table of Contents Lab 3 Using the Worklight Server and Environment Optimizations... 3-4 3.1 Building and Testing on the Android Platform...3-4 3.1.1 Adding a new Worklight environment... 3-5 3.1.2 Building and Testing the Android Application... 3-8 3.1.3 Optimizing for the Android Environment...3-13 3.2 Using In-App Notification via the Worklight Console... 3-20 3.3 Summary... 3-24 Page 3-2 Worklight 6.0 POT - Lab 3

Worklight 6.0 POT - Lab 3 Page 3-3

Lab 3 Using the Worklight Server and Environment Optimizations In Lab 1 and 2, you familiarized yourself with building and testing a mobile application using Worklight Studio. In Lab 3, you are going to continue to work with the application in the Worklight Studio, but you will also work with the Worklight Server. In this lab, you will learn how to do the following: Create a new Worklight environment in Worklight Studio Build and test an application for Android environments Use environment optimization capabilities in Worklight Use the direct update feature of Worklight Server 3.1 Building and Testing on the Android Platform IBM Worklight supports the deployment of mobile applications to multiple different operating system platforms. In Lab 1, you saw how to build and deploy applications to the ios platform. In this section of the lab, you will use the Worklight Studio to add support for the Android platform. Adding support for an additional platform that is supported by Worklight is an easy task. You start by adding a new Worklight environment for the desired platform, and then you can use the appropriate native tools to produce a device installable for the target platform. In the case of Android, Worklight integrates directly with the Android SDK, which means that you can build the device installable application and launch it on an emulator without leaving the Worklight Studio. Page 3-4 Worklight 6.0 POT - Lab 3

3.1.1 Adding a new Worklight environment In this part of the lab, you will add a new Worklight environment for Android. 1. In the workbench, expand the MyMemories Worklight project > expand apps folder > right-click on the MyMemories application folder > New > Worklight Environment. 2. Select the Android phones and tablets checkbox and click Finish. 3. You will see a new folder named android appears under the MyMemories application. In addition, a top-level project called MyMemoriesMyMemoriesAndroid now exists. Worklight 6.0 POT - Lab 3 Page 3-5

4. 5. The android environment folder under the MyMemories application folder will hold web and native content specific to the Android platform. The MyMemoriesMyMemoriesAndroid project was created automatically because the Android Development Tools (ADT) Eclipse Plugin has been installed into this environment. You can use this project to develop any native (Java for Android) code for your application. Expand the android environment > native > res > xml > open config.xml. 6. Switch to the config.xml tab. Page 3-6 Worklight 6.0 POT - Lab 3

7. Add the following line at the <preference> section. <preference name="loadurltimeoutvalue" value="60000" /> This is snippet #1 in C:\WorklightLab\imports\lab3\Lab3.snippets.txt. 8. 9. Save the config.xml file. Open AndroidManifest.xml file into the editor. It s under the native folder of the android environment. Worklight 6.0 POT - Lab 3 Page 3-7

10. Switch to the AndroidManifest.xml tab into the editor. 11. Replace <uses-sdk android:minsdkversion= 8 /> with the following line. <uses-sdk android:minsdkversion="8" android:targetsdkversion="16"/> This is snippet #2 in C:\WorklightLab\imports\lab3\Lab3.snippets.txt. 12. Save the AndroidManifest.xml file. 3.1.2 Building and Testing the Android Application In this part of the lab, you will test the MyMemories application on an Android Virtual Device (AVD). 1. Before testing the application on an AVD, you need to build and deploy the updated application to the Worklight Server. Expand MyMemories project > apps> right-click on the MyMemories > Run As > Build All and Deploy. Page 3-8 Worklight 6.0 POT - Lab 3

2. This will build the application with the new Android environment and deploy the updated artifacts to the embedded Worklight Server. When the build and deploy is complete, you should see success messages in the console view in the Worklight Studio. Worklight 6.0 POT - Lab 3 Page 3-9

3. In the workbench, select Window > Android Virtual Device Manager. 4. Select MyMemoriesAVD and click Start. 5. Press Launch to start the virtual device. Page 3-10 Worklight 6.0 POT - Lab 3

6. It takes the Android emulator awhile to start. Once the Android emulator started, you can close the Android Virtual Device Manager. 7. Change to the LogCat view while waiting for the emulator to start. You will begin to see logs from the emulator. 8. After the Android emulator is fully started, unlock the emulator by dragging the lock to the right. You will be at the home screen. Worklight 6.0 POT - Lab 3 Page 3-11

9. To run the app in the Android Virtual Device, right-click on the MyMemoriesMyMemoriesAndroid project. Click Run As > Android Application. 10. The MyMemories application will automatically open and start on the Android Virtual Device instance. If the MyMemories application is not open after unlocking, wait a few moments as the application installation completes. Once the application is installed and opened, you should see the home screen for the MyMemories application (Note: The layout of your Android Virtual Device may vary from the below image, depending on which target platform and API level are configured for you emulator). Page 3-12 Worklight 6.0 POT - Lab 3

11. 12. You can now test the application on the Android Virtual Device instance. Navigate to different screens by clicking on any of the icons or navigational buttons. To take a picture, the emulator will provide a green square animation and you can click the circle center button to take the picture. Click the checkmark to accept it. 13. When done testing the application exit the application on the Android Virtual Device. Do not close the Android Virtual Device instance as you will be using the application in the next section. 3.1.3 Optimizing for the Android Environment In this part of the lab, you will learn how to make optimizations for the MyMemories application when running on an Android platform. Additionally, you will discover the Direct Update feature of the Worklight runtime. You will be introducing JavaScript that is specific to the Android platform. In particular, you will use the Worklight client-side JavaScript API to dynamically create menu items. The menu items will provide an alternative means of navigation within the application so that you can get to any screen from any other screen in the application. The ability to create menu items is only applicable on the Android and Windows Phone platforms as other platforms (such as ios) do not have the concept of menus. 1. In the Eclipse workbench, navigate to the MyMemories project > apps > MyMemories > android > js directory. This directory holds all application JavaScript that is specific to the Android platform. The environment specific JavaScript directories follow a sparse model whereby developers only write code that overrides or augments what is in the common directory. In this way you can avoid writing duplicate code. Note that we are editing the Android JS file, not the common JS file. 2. Open MyMemories.js file into the editor. Currently the project does not contain environment specific code, so the MyMemories.js file under the android folder is mostly empty. It contains a single function called wlenvinit that is used to call the common initialization code when the application starts. Worklight 6.0 POT - Lab 3 Page 3-13

3. Delete all the code in the MyMemories.js file. Now you should have an empty editor. 4. Copy and paste Snippet #3 from C:\WorklightLab\imports\lab3\Lab3.snippets.txt to the empty editor. The code snippet replaces the original wlenvinit() method with contents which was deleted in the previous step. Save the file. /* * Licensed Materials - Property of IBM * 5725-G92 (C) Copyright IBM Corp. 2011, 2012. All Rights Reserved. * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ var itemlist = new Array(); // This method is invoked after loading the main HTML and successful initialization of the Worklight runtime. function wlenvinit(){ wlcommoninit(); // Environment initialization code goes here WL.OptionsMenu.init({opacity: "0.9"}); WL.OptionsMenu.addItem('homePage', function() {changepage("#homepage");}, 'Go to Home', {image:'', enabled : true}); itemlist.push('homepage'); WL.OptionsMenu.addItem('createMem', function() {changepage("#camerapage");}, 'Add Memory', {image:'', enabled : true}); itemlist.push('createmem'); WL.OptionsMenu.addItem('listMem', function() {changepage("#listpage");}, 'My Memories', {image:'', enabled : true}); itemlist.push('listmem'); WL.OptionsMenu.addItem('closeApp', function() {WL.App.close();}, 'Exit', {image:'', enabled : true}); Page 3-14 Worklight 6.0 POT - Lab 3

itemlist.push('closeapp'); WL.OptionsMenu.setEnabled(true); WL.OptionsMenu.setVisible(true); $(document).on('pagechange', handlepagechange); } function changepage(targetpage) { console.log('changing page to ' + targetpage); $.mobile.changepage(targetpage); } function handlepagechange(arg, obj) { enableall(); var pageid = $.mobile.activepage.attr('id'); var disableitem = null; if(pageid == 'homepage') { disableitem = WL.OptionsMenu.getItem('homePage'); } else if(pageid == 'camerapage') { disableitem = WL.OptionsMenu.getItem('createMem'); } else if(pageid == 'listpage') { disableitem = WL.OptionsMenu.getItem('listMem'); } } if(disableitem!= null) { disableitem.setenabled(false); } function enableall() { } itemlist.foreach(function(item) {WL.OptionsMenu.getItem(item).setEnabled(true);}); Worklight 6.0 POT - Lab 3 Page 3-15

In the wlenvinit() function, we will initiate the option menus. The majority of the code in the wlenvinit() function deals with using the WL.OptionsMenu API. This API is provided by Worklight and allows you to programmatically add menu items from within your application code. After creating each menu item using the WL.OptionsMenu.addItem API, the code enables the menu and makes it visible using the WL.OptionsMenu.setEnabled and WL.OptionsMenu.setVisible APIs. When creating the menu items, a function called changepage is referenced. The changepage function is called when a menu item is clicked and uses the changepage functionality built into jquery Mobile to navigate between screens in the application. The last line $(document).on('pagechange', handlepagechange)registers a callback handler on a page change event. This means that anytime a user navigates from one screen to another, the handlepagechange function is called. This function will take care of ensuring the correct menu items are enabled based on the screen that is currently active in the application. 5. Now that the changes are done, you need to build the updated version of the application. To do this, expand MyMemories project > apps > right-click on the MyMemories application folder > Run As > Build All and Deploy. This will build the application package with the changes, and it will deploy the updated application to the Worklight Server. Page 3-16 Worklight 6.0 POT - Lab 3

6. Wait until the build completes. Go back to the opened Android Virtual Device instance. Click on the home button which is the up arrow on the bottom of the emulator. 7. Click on the full application button to see all the available applications. Worklight 6.0 POT - Lab 3 Page 3-17

8. Click the MyMemories app to open the app again. 9. Once the application is open, you should see a prompt to update the application. Page 3-18 Worklight 6.0 POT - Lab 3

10. Click the Update button to begin the update process. Once clicked, the Worklight Device runtime will download the updated application contents from the Worklight Server. 11. 12. Once retrieved, the existing application contents are cleared from the disk cache, and the new contents are unpacked. When complete, the application is restarted from the new contents. To test your changes, you need to bring up the menu on the emulator instance. You can do this by pressing the menu icon on the emulator instance. You should see a menu that has an item for each screen in the application. Worklight 6.0 POT - Lab 3 Page 3-19

13. 14. Click on My Memories, Add Memory, or Go Home to navigate to any of the main application screens. Click the Home button to go to the Android home screen. 15. Keep the Android emulator running. DO NOT close the Android Virtual Device instance. 3.2 Using In-App Notification via the Worklight Console The Worklight console is where you control the mobile application. Each Worklight project has its own console for maintaining its assets which include the mobile app and the adapters. 1. To go to the Worklight Management Console for your Worklight project, right-click MyMemories project > Open Worklight Console. Page 3-20 Worklight 6.0 POT - Lab 3

2. The Worklight console should appear in a browser with URL similar to this: http://<hostname>:10080/<projectname>/console/#catalog Notice that there are the iphone and Android environments. The console is running on the Worklight Development Server with a default port of 10080. You can see the mobile app and adapter are both deployed in the console. Worklight 6.0 POT - Lab 3 Page 3-21

3. In the Worklight console, select Active, Notifying from the Android active drop-down box. 4. Enter Maintenance as the Notification Text and click Save. 5. You should see a message at the top of the console saying that the rule has been set. Page 3-22 Worklight 6.0 POT - Lab 3

6. Go back to the Android Virtual Device emulator. Click on the App button. 7. Relaunch the MyMemories app. Worklight 6.0 POT - Lab 3 Page 3-23

8. You should see the in-app notification. Click Close on the notification to continue using the app. 9. Close the MyMemoriesAVD the Android emulator. 3.3 Summary Congratulations! You have completed Lab 3. Page 3-24 Worklight 6.0 POT - Lab 3