Android - Technical Documentation
Transcription
Android - Technical Documentation
PureWeb® STK 3.1 Quick Start Guide: Android The information contained herein is proprietary and confidential and cannot be disclosed or duplicated without the prior written consent of Calgary Scientific Inc. Copyright © 2012 Calgary Scientific Inc. All rights reserved. About Calgary Scientific Calgary Scientific Inc., is dedicated to providing advanced web-enablement, mobility enhancement and advanced visualization solutions to industries looking for secure access and use of their data or graphics intensive applications, while using their existing systems. Visit www.calgaryscientific.com for more information. Notice Although reasonable effort is made to ensure that the information in this document is complete and accurate at the time of release, Calgary Scientific Inc., cannot assume responsibility for any existing errors. Changes and/or corrections to the information contained in this document may be incorporated in future versions. Your Responsibility for Your System’s Security You are responsible for the security of your system. Product administration to prevent unauthorized use is your responsibility. Your system administrator should read all documents provided with this product to fully understand the features available that reduce your risk of incurring charges for unlicensed use of Calgary Scientific products. Trademarks ResolutionMD, PureWeb, the Calgary Scientific logo, and the PureWeb logo are trademarks and/or registered trademarks of Calgary Scientific Inc. or its subsidiaries. All other trademarks and trade names referred to in this document are the property of other companies. Technical Support from Calgary Scientific Please contact Calgary Scientific Support at the regional numbers provided on page 8. Ordering and Licensing Information The PureWeb license is an ASCII text file with a .lic extension. The license is not part of the PureWeb Server installation, and must be acquired from Calgary Scientific Inc. When you receive your license, copy the .lic file in to the C:\CSI\PureWeb\Server\conf\ directory and (re)start the server. Released by Calgary Scientific Inc. www.calgaryscientific.com. Document Version: PW3.1_Android_QSG_08-2012_v3.100.00 Table of Contents List of Tasks ................................................................................................................... 5 List of Procedures ................................................................................................................... 6 Preface ................................................................................................................... 7 Intended Audience..................................................................................... 7 Reading Recommendations ...................................................................... 8 Making Comments on This Document ...................................................... 8 Contacting Calgary Scientific Support ....................................................... 8 Common Development Tasks.................................................................... 8 Chapter 1 Introducing PureWeb® STK ................................................................. 11 About PureWeb® STK ............................................................................. 11 Basic Architecture.................................................................................... 12 Prerequisites for Android Development................................................... 14 About the Sample Applications................................................................ 14 Chapter 2 Introducing ScribbleApp...................................................................... 15 About ScribbleApp................................................................................... 15 ScribbleApp Classes........................................................................... 16 ScribbleApp Code Description............................................................ 16 AndroidClient Classes ........................................................................ 16 AndroidClient Code Description.......................................................... 17 PureWeb Common Library Code Description..................................... 19 Build ScribbleApp .................................................................................... 21 Run ScribbleApp...................................................................................... 21 Sample Functionality ............................................................................... 21 Debug ScribbleApp.................................................................................. 26 Chapter 3 Introducing AsteroidsApp ................................................................... 27 About AsteroidsApp................................................................................. 27 Quick Start Guide: Android 3 Table of Contents AsteroidsApp Classes......................................................................... 28 AsteroidsApp Code Description .......................................................... 28 AndroidClient Classes ........................................................................ 28 AndroidClient Code Description.......................................................... 28 PureWeb Common Library Code Description..................................... 31 Build AsteroidsApp .................................................................................. 32 Run AsteroidsApp.................................................................................... 32 Sample Functionality ............................................................................... 32 Single-Player Mode Functionality ....................................................... 32 Two-Player Mode Functionality........................................................... 35 Debug AsteroidsApp................................................................................ 36 Chapter 4 Common Procedures ........................................................................... 37 Common Procedures............................................................................... 37 Supplements Related Documentation Resources ..................................................... 58 Document Conventions ........................................................................ 59 Index 4 ................................................................................................................. 61 PureWeb STK 3.1 List of Tasks Development Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Scribble Application Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Asteroids Application Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Quick Start Guide: Android 5 List of Procedures Changing Pen Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Sharing the Scribble Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 Sharing the Asteroids Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Building the Sample Service Application . . . . . . . . . . . . . . . . . . . . . . . . 37 Building the Scribble AndroidClient using Apache Ant . . . . . . . . . . . . . . 38 Building the Asteroids AndroidClient using Apache Ant . . . . . . . . . . . . . 40 Building the AndroidClient using Eclipse . . . . . . . . . . . . . . . . . . . . . . . . 42 Creating a Classpath Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Creating an Android Virtual Device (AVD) . . . . . . . . . . . . . . . . . . . . . . . 44 Importing the Sample Application into Eclipse . . . . . . . . . . . . . . . . . . . . 46 Creating a Sample Application Run Target . . . . . . . . . . . . . . . . . . . . . . 49 Configuring the Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Running the Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Debugging the AndroidClient Application . . . . . . . . . . . . . . . . . . . . . . . . 57 Quick Start Guide: Android 6 Preface Welcome to the PureWeb STK 3.1 Quick Start Guide: Android. Although every effort has been made to make this document clear and easy to understand, it is still very technical in nature. Wherever possible, cross-referencing among chapters and other documents within the PureWeb® Software Transformation Kit (STK) documentation suite has been used. This document is valid for all 3.x release(s) of this product. This preface contains the following sections: Intended Audience, page 7 Reading Recommendations, page 8 Making Comments on This Document, page 8 Contacting Calgary Scientific Support, page 8 Common Development Tasks, page 8 For information about related resources and about the conventions that are used in this document, see the supplementary material starting on page 58. Intended Audience This document is primarily intended for software developers who plan to install and use the PureWeb® STK. It has been written with the assumption that you have: • A working knowledge of Eclipse. • An intermediate knowledge of Java. • A degree of competency in Android applications and their deployment. Quick Start Guide: Android 7 Preface Reading Recommendations Reading Recommendations This preface includes task-based tables that contain all of the tasks and procedures needed to successfully build, run, and debug the PureWeb® sample applications. See Task Summary: Development Tasks, Task Summary: Scribble Application Tasks, and Task Summary: Asteroids Application Tasks. Making Comments on This Document If you especially like or dislike anything about this document, feel free to e-mail your comments to [email protected]. You can comment on what you regard as specific errors or omissions, and on the accuracy, organization, subject matter, or completeness of this document. Please limit your comments to the scope of this document only and to the way in which the information is presented. When you send us comments, you grant Calgary Scientific Inc. a nonexclusive right to use or distribute your comments in any way it believes appropriate, without incurring any obligation to you. Contacting Calgary Scientific Support Contact Calgary Scientific Support during the hours of 9:00AM - 5:00PM, Monday - Friday (Mountain Standard Time). Web Site E-Mail http://support.getpureweb.com [email protected] Common Development Tasks Common development tasks are listed in the table below. Task Summary: Development Tasks Task Procedure Familiarize yourself with PureWeb®. “About PureWeb® STK” on page 11. “Basic Architecture” on page 12. Ensure that you have the required development prerequisites. 8 “Prerequisites for Android Development” on page 14. PureWeb STK 3.1 Preface Common Development Tasks Common Scribble Application tasks are listed in the table below. Task Summary: Scribble Application Tasks Task Procedure Familiarize yourself with the ScribbleApp “About ScribbleApp” on page 15. classes and code. Build the ScribbleApp Service application. “Building the Sample Service Application” on page 37. Build the Scribble AndroidClient application. You have two options for building the AndroidClient application: • “Building the Scribble AndroidClient using Apache Ant” on page 38. • “Building the AndroidClient using Eclipse” on page 42. Run the ScribbleApp. “Configuring the Sample Application” on page 53. Exercise the ScribbleApp functionality. “Sample Functionality” on page 21. You may find it helpful to debug the Scribble AndroidClient application. “Debugging the AndroidClient Application” on page 57. You may find it helpful to debug the ScribbleApp Service application. To debug the sample service application, refer to the PureWeb® STK Quick Start Guide: Java. Common Asteroids Application tasks are listed in the table below. Task Summary: Asteroids Application Tasks Task Procedure Familiarize yourself with the AsteroidsApp classes and code. “About AsteroidsApp” on page 27. Build the AsteroidsApp Service application. “Building the Sample Service Application” on page 37. Build the AsteroidsApp application. You have two options for building the AndroidClient application: • “Building the Scribble AndroidClient using Apache Ant” on page 38. • “Building the AndroidClient using Eclipse” on page 42. Run the Asteroids application. “Configuring the Sample Application” on page 53. Exercise the AsteroidsApp functionality. “Sample Functionality” on page 32. Quick Start Guide: Android 9 Preface Common Development Tasks Task Summary: Asteroids Application Tasks (Continued) Task Procedure You may find it helpful to debug the Asteroids AndroidClient application. “Debugging the AndroidClient Application” on page 57. You may find it helpful to debug the AsteroidsApp Service application. To debug the sample service application, refer to the PureWeb® STK Quick Start Guide: Java. 10 PureWeb STK 3.1 Chapter 1 Introducing PureWeb® STK This chapter contains detailed information about the PureWeb® Software Transformation Kit (STK) solution and its architecture. It also contains information about prerequisites needed for Android development using the PureWeb® STK. This chapter contains the following sections: About PureWeb® STK, page 11 Basic Architecture, page 12 Prerequisites for Android Development, page 14 About the Sample Applications, page 14 About PureWeb® STK PureWeb® is a platform that enables applications to be centrally hosted and delivered to the end user, from workstations to hand-held devices, through standard web technologies. PureWeb® allows you to migrate your existing desktop applications to the web without requiring a costly rewrite of your existing applications. The PureWeb® application framework is built specifically to leverage HTTP and XML for the highest level of flexibility, optimization, consistency and performance. Its architecture is designed to use web standard technologies to deliver your applications through all internet browsers capable of hosting Microsoft Silverlight, as well as in many smart phones and tablet offerings, using the PureWeb® API. PureWeb® integrates directly into your existing C#, C++, Flash, or Java code and allows you to maintain one code-base from which you can deliver desktop-based applications as well as browser and mobile-based applications such as those that run on Apple iPad, Apple iPhone or Google Android devices. Quick Start Guide: Android 11 Chapter 1: Introducing PureWeb® STK Basic Architecture Applications that leverage PureWeb® provide access in a highly secure and compliant manner, so mobile users can connect to your applications and interact with them as if they were stored locally on their device without any of the application data ever persisting on the device itself. This is achieved by: • Reimplementing the existing software user interface (UI) through a web interface. • Modifying the application to act as a service for the remote interface. The PureWeb® STK includes both sample applications and documentation to help you with your development. For more information about the product, visit http://www.getpureweb.com. Basic Architecture The PureWeb® platform enables applications to run through a standardized web interface. PureWeb® solutions are typically composed of three tiers: • PureWeb® Service—contains most of the application logic. It uses the Service API to plug in to the PureWeb® Server, maintain application state, and generate rendered views. • PureWeb® Server—is responsible for starting/stopping PureWeb® Services, and mediating communication between PureWeb® Clients and PureWeb® Services. • PureWeb® Client—allows users to interact with PureWeb® Services through web browsers and/or mobile devices. To PureWeb® enable an existing application means transforming the workstation version of an application into a PureWeb® Service by creating objects and calling methods from the Service API. Specifically, the application will create an instance of the StateManager class (responsible for maintaining application state in a PureWeb® Service) and pass it to an instance of StateManagerServer. The StateManagerServer handles communication with the PureWeb® Server over a TCP socket. Messages arriving from the client via the Server as XML text are converted to lists of command objects that are executed by the StateManager. These include commands to change the application state, commands that represent user input events, and custom commands understood by the application. In executing the commands, the application will generate response objects including changes to the application state and new rendered images. The StateManagerServer converts the response objects to XML and multipart messages that are passed back to the client via the PureWeb® Server. 12 PureWeb STK 3.1 Chapter 1: Introducing PureWeb® STK Basic Architecture Once the service creates the StateManager instance, it will register event handlers that are invoked when specific nodes in the application state change. Every rendered view that is intended to be displayed on the client must be registered with the StateManager. In order to communicate with the StateManager, views must inherit from the IRenderedView interface. Use the adapter pattern (http://en.wikipedia.org/wiki/Adapter_pattern), if it is not possible or convenient for view classes to inherit directly from the IRenderedView interface. Figure 1: Typical PureWeb® Solution As shown in Figures 2, the application state is stored on both the client and server sides as XML. To maintain synchronicity, the differences in the state are transmitted to and from both the client and the service. The client sends commands and input events to the service (in XML form). The service sends updated images to the client. Figure 2: State Views Quick Start Guide: Android 13 Chapter 1: Introducing PureWeb® STK Prerequisites for Android Development Prerequisites for Android Development The following is required for Android development: • Read and follow the instructions provided by Google for getting started with Android development at http://developer.android.com/sdk/index.html. • We recommend using Eclipse Indigo Classic (version 3.7.2) found at http://www.eclipse.org/downloads/ and installing the Android Development Tools (ADT) plugin for the Eclipse IDE found at http://developer.android.com/sdk/eclipse-adt.html for development with the PureWeb® Android STK. Note: Eclipse for Android is limited to version 3.5 (or greater). For detailed information, see http://developer.android.com/sdk/requirements.html. • Install a minimum of Android SDK Level 7(2.1) into your Eclipse environment. • Ensure the Android tools directory is in your Path variable. • Ensure the Android platform-tools directory is in your Path variable. The Android Debug Bridge (adb) tool is used in the Building with Apache Ant process. About the Sample Applications Although, only a 64-bit platform is supported for application development, you can target the applications developed using the PureWeb® STK to deploy on either a 32-bit or a 64-bit platform. The following sample applications are included to illustrate the fundamentals of using the PureWeb® STK: 14 • ScribbleApp—Exercises the functionality of drawing lines, changing line color, and erasing lines. • AsteroidsApp—Enables two individuals to work together within the same application. PureWeb STK 3.1 Chapter 2 Introducing ScribbleApp This section provides detailed information about the Android ScribbleApp sample application. It includes information about the classes and methods used in the sample, as well as, information about building, running, and debugging the sample application. This chapter contains the following sections: About ScribbleApp, page 15 Build ScribbleApp, page 21 Run ScribbleApp, page 21 Sample Functionality, page 21 Debug ScribbleApp, page 26 About ScribbleApp Read the section titled “Basic Architecture” on page 12 to gain an understanding of how the client, service and server components of a PureWeb®-enabled solution are connected, the kinds of data that are exchanged between client, service and server, the role of the application state on the client, service and server-sides, and how that state is synchronized. The sample application consists of three components: • ScribbleApp—A PureWeb®-enabled service application that implements the scribble application logic. • AndroidClient—A PureWeb®-enabled client application that presents a remote interface to the service application. • PureWeb® Common Library—A library common to both samples that provides common functionality. Quick Start Guide: Android 15 Chapter 2: Introducing ScribbleApp About ScribbleApp The source code for: • ScribbleApp is located at C:\CSI\PureWeb\SDK\Samples\Java. • AndroidClient is located at C:\CSI\PureWeb\SDK\Samples\Android\scribble. • PureWeb® Common Library is located at C:\CSI\PureWeb\SDK\Samples\Android\pureweb. ScribbleApp Classes For detailed information about the ScribbleApp classes, refer to the ScribbleApp Classes section of the PureWeb® STK Quick Start Guide: Java. ScribbleApp Code Description For detailed information about the ScribbleApp code, refer to the ScribbleApp Code Description section of the PureWeb® STK Quick Start Guide: Java. AndroidClient Classes The PureWeb® Android STK consists of many of the same classes found in the PureWeb® Java Client (Swing) STK; see the ScribbleClient Classes section of the PureWeb® STK Quick Start Guide: Java for details. There are only two public classes specific to the Android platform: • pureweb.android.client.AndroidUiDispatcher—provides the underlying PureWeb® APIs with a way to dispatch commands and application state changes to the user interface (UI) thread. • pureweb.android.client.ui.View—is the only UI widget provided by the PureWeb® STK. View extends from an android.view.View to provide the main rendering interface. 16 PureWeb STK 3.1 Chapter 2: Introducing ScribbleApp About ScribbleApp AndroidClient Code Description The onCreate method of the ScribbleAppActivity class, calls the onCreate() method of the PureWebActivity base class. It also calls PureWebActivity.connect() which determines if the redirect URL or the login view should be displayed. Finally, it registers a value changed handler to listen for color changes from a collaborator. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // show the login view or the redirect URL and wait for onConnected to be called once //the connection is made connect(PUREWEB_SERVER_URL); // add a value changed handler to listen for color changes framework.getState().getStateManager().addValueChangedHandler ("/ScribbleColor", new ColorChangedHandler()); } The onDestroy method called the PureWebActivity.disconnect() method. @Override public void onDestroy() { super.onDestroy(); disconnect(); } The onOptionsItemSelected method contains a switch statement with six possible cases: • case R.id.clear—erases the canvas and refreshes the view. • case R.id.close—closes the application. • case R.id.change_color—displays the color change dialog. The color change dialog creates a drop down box containing color choices, an Ok menu option, and a Cancel menu option. The Ok menu option sets the pen to the selected color. • case R.id.settings—displays the setting dialog. The setting dialog allows you to enable security, set the serverUrl, the User Name, and the Password. • case R.id.connect—calls the connect method. • case R.id.share—creates an email containing the shareUrl. public boolean onOptionsItemSelected(MenuItem item) { ... case R.id.change_color: // show the color change dialog AlertDialog.Builder builder = new AlertDialog.Builder(this); Quick Start Guide: Android 17 Chapter 2: Introducing ScribbleApp About ScribbleApp LayoutInflater li = LayoutInflater.from(this); final android.view.View colorView = li.inflate(R.layout.colordialog, null); PureWebKnownColor[] colors = PureWebKnownColor.values(); final String[] colorNames = new String[colors.length]; for (int i = 0; i < colors.length; i++) { colorNames[i] = colors[i].name(); } final Spinner spinner = (Spinner) colorView.findViewById(R.id.colorSpinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, colorNames); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setSelection(lastColor); builder.setPositiveButton("Ok", new OnClickListener() { public void onClick(DialogInterface dialog, int id) { ... } }); builder.setNegativeButton("Cancel", new OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); ... } We recommend subclassing this View to best translate touch and gesture events into commands for your back-end process. By default, we provide a mapping of touches to mouse events. Table 1: Mapping of Touched to Mouse Events 18 Touches Mouse Events Single-finger drag Left mouse button + move PureWeb STK 3.1 Chapter 2: Introducing ScribbleApp About ScribbleApp PureWeb Common Library Code Description The PureWebActivity base class provides functionality common to both the Scribble and Asteroids samples, including the ability to display a login view or a redirect URL, connect/disconnect from a PureWeb service application, and display common error dialogs. The onCreate() method is called by the ScribbleAppActivity.onCreate() method. It creates the Android UI dispatcher, and PureWeb Framework instance. It also sets up a stall changed handler to display a connection stalled warning dialog. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // make sure the preferences get loaded (this loads the defaults if this if the first time the app has been run). PreferenceManager.setDefaultValues(getApplicationContext(), R.xml.preferences, true); dispatcher = new AndroidUiDispatcher(); framework = new Framework(dispatcher); framework.getWebClient().addStalledChangedHandler(new ConnectionStalledHandler()); } The ScribbleAppActivity.onCreate() method also calls the PureWebActivity.connect() method. The method will determine where a share URL or a login view should be displayed. /** * Connect to the service application handling the case where the connection is via a browser redirect to a shared * session. * @param serverUrl the serverUrl to use for connection if not connecting to a shared session */ protected void connect(String serverUrl) { // check if we are connecting to a share URL, and if not display the login view and wait for onConnected to //be called once the connection is made Uri rawUri = getIntent().getData(); if (rawUri != null) { connectToSharedSession(rawUri); } else { showLoginView(serverUrl); } } The onConnected() method connects to the service app, and when the connection is successfully established, it returns to the ScribbleAppActivity.onConnected() method, so that it can display its main content view: @Override protected void onConnected() Quick Start Guide: Android 19 Chapter 2: Introducing ScribbleApp About ScribbleApp { // filter mouse events framework.getState().setValue("/PureWeb/ClientCommandFiltering", true); // inflate the layout, create the scribble view and add it to the layout LayoutInflater li = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) li.inflate(R.layout.main, null); view = new View(ScribbleAppActivity.this, framework); view.setViewName("ScribbleView"); layout.addView(view); setContentView(layout); } When you chose the Share menu option in the AndroidClient application, the ShareRequestCompleted class creates the email form that contains the shareUrl. protected class ShareRequestCompleted implements GetSessionShareUrlCallback { public ShareRequestCompleted() {} public void invoke(String shareUrl, final Throwable exception) { if (shareUrl != null){ Intent emailIntent = new Intent(Intent.ACTION_SEND); String[] recipients = new String[]{"[email protected]"}; emailIntent.putExtra(Intent.EXTRA_EMAIL, recipients); String appName = getResources().getString(R.string.app_name); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Please join my " + appName + " session"); emailIntent.putExtra(Intent.EXTRA_TEXT, shareUrl); emailIntent.setType("text/plain"); startActivity(Intent.createChooser(emailIntent, "Send mail...")); } else{ UiDispatcherUtil.beginInvoke(new Runnable(){ public void run() { AlertDialog.Builder errorDialogBuilder = new AlertDialog.Builder(PureWebActivity.this); errorDialogBuilder.setIcon(pureweb.samples.R.drawable.ic_pureweb); errorDialogBuilder.setTitle("An error occurred creating the Share URL"); errorDialogBuilder.setMessage("Unexpected exception: " + exception.getMessage()); errorDialogBuilder.setCancelable(false); errorDialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int id){ dialog.dismiss(); }... The disconnect() method is called by the ScribbleAppActivity.onDestroy() method. It disconnects the client from the service application. protected void disconnect() { if (framework != null && framework.getWebClient().isConnected()){ final CountDownLatch waitLatch = new CountDownLatch(1); // disconnect on non-UI thread (network operations not allowed on the UI thread in Android 3.x and higher) 20 PureWeb STK 3.1 Chapter 2: Introducing ScribbleApp Build ScribbleApp new Thread(new Runnable(){ public void run(){ try { framework.getWebClient().disconnect(); } catch (IOException e) { // fail silently on quit } finally { waitLatch.countDown(); } } }).start();... Build ScribbleApp Both the ScribbleApp service application and the AndroidClient must be built to run the ScribbleApp sample. Use the “Building the Sample Service Application” procedure to build the service application. Use either the “Building the Scribble AndroidClient using Apache Ant” procedure or the “Building the AndroidClient using Eclipse” procedure to build the client application. Run ScribbleApp To run the application using the simulator, a 3.0 capable tablet, or a 2.1 capable Android phone connected via USB with debugging enabled by following the steps in the “Running the Sample Application” procedure. For more information about running Android applications, see http://developer.android.com/guide/developing/device.html. Sample Functionality The Scribble AndroidClient application supports the following functionality: • Configure the application from the Settings page. The sample must be configured to function, refer to the “Configuring the Sample Application” procedure for instructions on how to configure your application. • Log in to the application from the Login page. • Draw lines on the canvas by left-clicking the mouse and dragging. • Change colors by selecting a new color in the Select a pen dialog. • Clear the canvas by clicking on the Clear menu option. • Close the application by clicking on the Close menu option. Quick Start Guide: Android 21 Chapter 2: Introducing ScribbleApp • Sample Functionality Share the application and launch an email application to send the Share Url by clicking on the Share menu option. Launching the sample application displays the Login page. Figure 3: Login Page Left-click and drag your mouse to draw lines on the canvas. Figure 4: Drawing 22 PureWeb STK 3.1 Chapter 2: Introducing ScribbleApp Sample Functionality Display the AndroidClient menu by clicking on the Menu button either through the emulator control panel, or on the device itself. Figure 5: Display the Menu Erase the lines on the canvas by clicking the Clear menu option. Changing Pen Colors Purpose: To change colors. Start of procedure 1. Click the Change Color menu option to display the Select a pen color dialog. Figure 6: Select a Pen Dialog Quick Start Guide: Android 23 Chapter 2: Introducing ScribbleApp Sample Functionality 2. Click the drop down list arrow to display the Color Selection list. Figure 7: Color Selection List 3. Click the option button of your chosen color to return to the Select a pen color dialog. 4. Click the Ok menu option to commit your change or the Cancel menu option to keep your current color, see Figure 6. Figure 8: Color Red End of procedure 24 PureWeb STK 3.1 Chapter 2: Introducing ScribbleApp Sample Functionality Sharing the Scribble Application Purpose: To share the Scribble application. Start of procedure First person: 1. Click the Share menu option located on the AndroidClient menu, see Figure 5, to open an email application. 2. Send a second person the URL displayed in the body of the email. Second person: 1. Open the received message and click on the URL to display the PureWeb Collaboration Login page in your browser. 2. Select your Preferred Client from the drop down box, enter Scientific as your Password and click the Sign In button to join the AndroidClient session. Figure 9: Collaboration Login Page End of procedure Close AndroidClient by clicking on the Close menu option, see Figure 5. . Note: To properly disconnect the client from the server, always close your application using the Home or Back buttons. Closing the application by any other means will leave orphan processes running. Quick Start Guide: Android 25 Chapter 2: Introducing ScribbleApp Debug ScribbleApp Debug ScribbleApp To debug the sample service application, refer to the PureWeb® STK Quick Start Guide: Java. To debug the AndroidClient application follow the steps in the “Debugging the AndroidClient Application” procedure. 26 PureWeb STK 3.1 Chapter 3 Introducing AsteroidsApp This section provides detailed information about the Android AsteroidsApp sample application. It includes information about the classes and methods used in the sample, as well as information about building, running, and debugging the sample application. Note that the AsteroidsApp sample application shares many similarities with the ScribbleApp sample, particularly with respect to PureWeb®-enablement. If you have not already done so, you may find it helpful to read Chapter 2, “Introducing ScribbleApp,” on page 15 first. This chapter contains the following sections: About AsteroidsApp, page 27 Build AsteroidsApp, page 32 Run AsteroidsApp, page 32 Sample Functionality, page 32 Debug AsteroidsApp, page 36 About AsteroidsApp AsteroidsApp is a sample application intended to illustrate the collaboration capabilities of PureWeb®. It is a PureWeb®-enabled implementation of the classic video game with a twist—it supports both single-player, and two-player modes. In two-player mode, each player independently controls his or her own ship. The sample application consists of two components: • AsteroidsApp—A PureWeb®-enabled service application that implements the asteroids game logic. • AndroidClient—A PureWeb®-enabled client application that presents a remote interface to the service application. • PureWeb® Common Library—A library common to both samples that provides common functionality. Quick Start Guide: Android 27 Chapter 3: Introducing AsteroidsApp About AsteroidsApp The source code for: • AsteroidsApp is located at C:\CSI\PureWeb\SDK\Samples\Java. • AndroidClient is located at C:\CSI\PureWeb\SDK\Samples\Android\asteroids. • PureWeb® Common Library is located at C:\CSI\PureWeb\SDK\Samples\Android\pureweb. AsteroidsApp Classes For detailed information about the AsteroidsApp classes, refer to the AsteroidsApp Classes section of the PureWeb® STK Quick Start Guide: Java. AsteroidsApp Code Description For detailed information about the AsteroidsApp code, refer to the AsteroidsApp Code Description section of the PureWeb® STK Quick Start Guide: Java. AndroidClient Classes The PureWeb® Android STK consists of many of the same classes found in the PureWeb® Java Client (Swing) STK; see the AsteroidsClient Classes section of the PureWeb® STK Quick Start Guide: Java for details. There are only two public classes specific to the Android platform: • pureweb.android.client.AndroidUiDispatcher—provides the underlying PureWeb® APIs with a way to dispatch commands and application state changes to the user interface (UI) thread. • pureweb.android.client.ui.View—is the only UI widget provided by the PureWeb® STK. View extends from an android.view.View to provide the main rendering interface. AndroidClient Code Description In the onCreate method of the AsteroidsAppActivity class, calls the onCreate() method of the PureWebActivity base class. It also calls PureWebActivity.connect() which determines if the redirect URL or the login view should be displayed. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // show the login view or the redirect URL and wait for onConnected to be called once the //connection is made connect(PUREWEB_SERVER_URL); } Quick Start Guide: Android 28 Chapter 3: Introducing AsteroidsApp About AsteroidsApp The onDestroy method called the PureWebActivity.disconnect() method. @Override public void onDestroy() { super.onDestroy(); disconnect(); } The onOptionsItemSelected method contains an if/else statement with four possible results: • case R.id.close—closes the application. • case R.id.settings—displays the setting dialog. The setting dialog allows you to enable security, set the serverUrl, the User Name, and the Password. • case R.id.connect—calls the connect method. • case R.id.share—creates an email containing the shareUrl. @Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.settings) { Intent settingsIntent = new Intent(getBaseContext(), SettingsActivity.class); settingsIntent.putExtra(SettingsActivity.PREFERENCE_RES_ID_KEY, R.xml.preferences); startActivityForResult(settingsIntent, PureWebActivity.SETTINGS_REQUEST_CODE); return true; } else if (itemId == R.id.share){ framework.getWebClient().getSessionShareUrlAsync ("Scientific", "", 1800000, "", new ShareRequestCompleted()); return true; } else if (itemId == R.id.close){ finish(); return true; } else { return false; }... Quick Start Guide: Android 29 Chapter 3: Introducing AsteroidsApp About AsteroidsApp The onTouch method handles game button touches. It translates the button presses/releases into keyboard events. This method calls the queueKeyboardEvent which is described later. @Override public boolean onTouch(android.view.View v, MotionEvent event) { // determine whether this is a key down or up event KeyboardEventType eventType; int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_1_DOWN: case MotionEvent.ACTION_POINTER_2_DOWN: case MotionEvent.ACTION_POINTER_3_DOWN: eventType = KeyboardEventType.KeyDown; break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_1_UP: case MotionEvent.ACTION_POINTER_2_UP: case MotionEvent.ACTION_POINTER_3_UP: eventType = KeyboardEventType.KeyUp; break; ... } pointerIndex = event.getPointerId(pointerIndex); // determine which button was pressed (if any) if (eventType == KeyboardEventType.KeyDown) { if (pointerIndex == 0) { pressedButtonId[0] = v.getId(); } else { int[] xy = new int[2]; getScreenCoordinates(v.getId(), (int)event.getX(pointerIndex), (int)event.getY(pointerIndex), xy); pressedButtonId[pointerIndex] = getGameButtonId(xy[0], xy[1]); ... queueKeyboardEvent(pressedButtonId[pointerIndex], eventType); ... } Quick Start Guide: Android 30 Chapter 3: Introducing AsteroidsApp About AsteroidsApp The queueKeyboardEvent method creates a PureWeb InputCommand for the keyboard events that correspond to the game buttons. It uses a switch statement with a case for each of the game buttons (fire, shields, forward, reverse, left, and right). The information is put into a queue to be sent to the Asteroids service application. private void queueKeyboardEvent(int button, KeyboardEventType eventType) { KeyCode keyCode; if (button == R.id.fire) { keyCode = KeyCode.Space; } else if (button == R.id.shields) { keyCode = KeyCode.S; } else if (button == R.id.forward) { keyCode = KeyCode.Up; } else if (button == R.id.reverse) { keyCode = KeyCode.Down; } else if (button == R.id.left) { keyCode = KeyCode.Left; } else if (button == R.id.right) { keyCode = KeyCode.Right; } else { return; // not a game button - ignore! } Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("EventType", eventType); parameters.put("Path", "AsteroidsView"); parameters.put("KeyCode", keyCode.getKeyCode()); parameters.put("CharacterCode", 0); parameters.put("Modifiers", Modifiers.None.toInt()); framework.getWebClient().queueCommand("InputEvent", parameters); if (eventType == KeyboardEventType.KeyDown) { view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY); } } PureWeb Common Library Code Description For detailed information about the PureWeb Common Library code, refer to “PureWeb Common Library Code Description” on page 19. Quick Start Guide: Android 31 Chapter 3: Introducing AsteroidsApp Build AsteroidsApp Build AsteroidsApp Both the AsteroidsApp service application and the AndroidClient must be built to run the AsteroidsApp sample. Use the “Building the Sample Service Application” procedure to build the service application. Use either the “Building the Scribble AndroidClient using Apache Ant” procedure or the “Building the AndroidClient using Eclipse” procedure to build the client application. Run AsteroidsApp To run the application using the simulator, a 3.0 capable tablet, or a 2.1 capable Android phone connected via USB with debugging enabled by following the steps in the “Running the Sample Application” procedure. For more information about running Android applications, see http://developer.android.com/guide/developing/device.html. Sample Functionality The Asteroids AndroidClient application functions in both single-player and two-player mode. Single-Player Mode Functionality To play the Asteroids AndroidClient application: • Configure the application from the Settings page. The sample must be configured to function, refer to the “Configuring the Sample Application” procedure for instructions on how to configure your application. • Log in to the application from the Login page. • Press any key to start the game. • Use the up/down arrow icons to move forward/reverse. • Use the left/right arrow icons to change your heading. • Press the red button icon to fire torpedoes. • Activate shields by pressing the shield icon. Each player gets 5 seconds of shield time per game. Note that in two-player mode, shields are also enabled. • Close the application by clicking on the Close menu option. • Share the application and launch an email application to send the Share Url by clicking on the Share menu option. Quick Start Guide: Android 32 Chapter 3: Introducing AsteroidsApp Sample Functionality Launching the sample application displays the Login page. Figure 10: Login Page Press any key to start the game. Figure 11: Asteroids Quick Start Guide: Android 33 Chapter 3: Introducing AsteroidsApp Sample Functionality Display the AndroidClient menu by clicking on the Menu button either through the emulator control panel, or on the device itself. Figure 12: Display the Menu Sharing the Asteroids Application Purpose: To share the Asteroids application. Start of procedure Player one: 1. Click the Share menu option located on the AndroidClient menu, see Figure 12, to open an email application. 2. Send a second player the URL displayed in the body of the email. Quick Start Guide: Android 34 Chapter 3: Introducing AsteroidsApp Sample Functionality Player two: 1. Open the received message and click on the URL to display the PureWeb Collaboration Login page in your browser. 2. Select your Preferred Client from the drop down box, enter Scientific as your Password and click the Sign In button to join the AndroidClient session. Figure 13: Collaboration Login Page Close AndroidClient by clicking on the Close menu option, see Figure 12. Warning! To disconnect the client from the server properly, always close your application using the Home or Back buttons. Closing the application by any other means will leave orphan processes running. Two-Player Mode Functionality Additional two-player mode functionality includes: • Collide with an asteroid with your shields up to destroy the asteroid and collect the points. • Collide with an unshielded opponent with your shields up to destroy their ship and collect all of their points. Similarly, you can shoot your opponent to destroy their ship and collect all their points. • Collide with a shielded opponent with your shields up to create an elastic collision. Quick Start Guide: Android 35 Chapter 3: Introducing AsteroidsApp Debug AsteroidsApp Debug AsteroidsApp To debug the sample service application, refer to the PureWeb® STK Quick Start Guide: Java. To debug the AndroidClient application follow the steps in the “Debugging the AndroidClient Application” procedure. Quick Start Guide: Android 36 Chapter 4 Common Procedures This chapter includes procedures that are common to all sample applications. This chapter contains the following sections: Common Procedures, page 37 Common Procedures You will be directed to use these procedures whenever it is appropriate. Building the Sample Service Application Purpose: To build and deploy the sample service application from the command line. Prerequisites • You must have installed Apache Ant installed by following the procedures in the PureWeb® Installation Guide for Microsoft Windows to download and install Apache Ant and to set your ANT_HOME and Path environment variables. Start of procedure 1. Follow the steps in the Building with Apache Ant procedure in the PureWeb® Quick Start Guide: Java. 2. Follow the steps in the Reloading a Plugin procedure in the PureWeb® Server Administration Guide. End of procedure Quick Start Guide: Android 37 Chapter 4: Common Procedures Common Procedures Next Steps • Use either the “Building the Scribble AndroidClient using Apache Ant” procedure or the “Building the AndroidClient using Eclipse” procedure to build the client application. Building the Scribble AndroidClient using Apache Ant Purpose: To build the Scribble AndroidClient using Apache Ant. Prerequisites • You must have Apache Ant installed. For details see the PureWeb® Installation Guide for Windows. • You must have your environment variables set to use Apache Ant. For details see the PureWeb® Installation Guide for Windows. Start of procedure 1. Launch the PureWeb Apache Tomcat Server with the Start PureWeb desktop icon. 2. Open a console window. 3. Change directories to C:\CSI\PureWeb\SDK\Samples\Android. 4. Setup path to point to the Android SDK tools directory by typing the following commands: • android update project --target 7 --path ./pureweb • android update project --target 7 --path ./scribble 5. Copy the following .jar files from C:\CSI\PureWeb\SDK\Redistributable\Libs\Android to C:\CSI\PureWeb\SDK\Samples\Android\pureweb\libs: • • • • CSI.PureWeb.Android.Client.jar CSI.PureWeb.Client.jar jdom.jar slf4j-android-1.5.8.jar 6. Change directories to C:\CSI\PureWeb\SDK\Samples\Android\Scribble. Figure 14: Update Properties File 38 PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures Note: The .apk file cannot be installed if a device is not connected, or an emulator is not running. Skip steps 7-10 if a device is connected. Note: If you have not created an Android Virtual Device (AVD) yet, follow the steps in the “Creating an Android Virtual Device (AVD)” procedure. 7. Open the Android AVD Manager. 8. Select AVD2.1. 9. Click the Start button. Figure 15: Start a Virtual Device 10. Click the Launch button. Figure 16: Launch the Virtual Device 11. Type the following command to create and install a debug build: • Quick Start Guide: Android ant debug install 39 Chapter 4: Common Procedures Common Procedures Note: Additional build targets can be listed by typing: ant. Note: If you switch between development using Eclipse and Apache Ant, you may need to remove the application from the device or emulator using the built-in Application Management Tool. For more information about development outside of Eclipse, see http://developer.android.com/guide/developing/other-ide.html. End of procedure Next Steps • “Building the Asteroids AndroidClient using Apache Ant”. Building the Asteroids AndroidClient using Apache Ant Purpose: To build the Asteroids AndroidClient using Apache Ant. Prerequisites • You must have Apache Ant installed. For details see the PureWeb® Installation Guide for Windows. • You must have your environment variables set to use Apache Ant. For details see the PureWeb® Installation Guide for Windows. • You must have built the Scribble AndroidClient by following the steps in the “Building the Scribble AndroidClient using Apache Ant” procedure. Start of procedure 1. Launch the PureWeb Apache Tomcat Server with the Start PureWeb desktop icon. 2. Open a console window. 3. Change directories to C:\CSI\PureWeb\SDK\Samples\Android. 4. Setup path to point to the Android SDK tools directory by typing the following command: • android update project --target 7 --path ./asteroids 5. Change directories to C:\CSI\PureWeb\SDK\Samples\Android\Asteroids. 40 PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures Note: The .apk file cannot be installed if a device is not connected, or an emulator is not running. Skip steps 6-9 if a device is connected. Note: If you have not created an Android Virtual Device (AVD) yet, follow the steps in the “Creating an Android Virtual Device (AVD)” procedure. 6. Open the Android AVD Manager. 7. Select AVD2.1. 8. Click the Start button. Figure 17: Start a Virtual Device 9. Click the Launch button. Figure 18: Launch the Virtual Device 10. Type the following command to create and install a debug build: • Quick Start Guide: Android ant debug install 41 Chapter 4: Common Procedures Common Procedures Note: Additional build targets can be listed by typing: ant. Note: To use both Eclipse and Ant builds, the classpath variable for the Eclipse build should be set to point to C:\CSI\PureWeb\SDK\Samples\Android\pureweb\libs rather than C:\CSI\PureWeb\SDK\Redistributable\Libs\Android. End of procedure Next Steps • Follow the steps in the “Configuring the Sample Application” procedure. Building the AndroidClient using Eclipse Purpose: To import the AndroidClient application and then create a run target, so that you can build the application using Eclipse. Start of procedure 1. Following the steps in “Creating a Classpath Variable” on page 43. 2. Following the steps in “Creating an Android Virtual Device (AVD)” on page 44. 3. Follow the steps in “Importing the Sample Application into Eclipse” on page 46. 4. Follow the steps in “Creating a Sample Application Run Target” on page 49. End of procedure 42 PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures Creating a Classpath Variable Purpose: To create an PUREWEB_SDK classpath variable. Start of procedure 1. Open Eclipse. 2. Select Windows | Preferences form the Main Menu. 3. Expand Java | Build Path and select Classpath Variables. 4. Click New to open the New Variable Entry dialog. Figure 19: Preferences 5. Enter PUREWEB_SDK in the Name field. 6. Enter C:\CSI\PureWeb\SDK\Redistributable\Libs\Android in the Path field. 7. Click OK to close the New Variable Entry dialog. Figure 20: New Variable Entry Dialog 8. Click OK to close the Preferences dialog. End of procedure Quick Start Guide: Android 43 Chapter 4: Common Procedures Common Procedures Creating an Android Virtual Device (AVD) Purpose: To create an Android Virtual Device using the AVD Manager. Start of procedure 1. Open the AVD Manager. Figure 21: AVD Manager 2. Click the New button to open the Create New AVD dialog. 3. Enter AVD2.1 in the Name field. 4. Select Android 4.0.3 API Level 15 from the Target drop down box. Figure 22: Create a New AVD 44 PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures 5. Click the Create AVD button to create the AVD. Figure 23: New AVD 6. Close the Android AVD Manager. End of procedure Quick Start Guide: Android 45 Chapter 4: Common Procedures Common Procedures Importing the Sample Application into Eclipse Purpose: To import the sample application project into Eclipse. Start of procedure 1. Select File | Import from the Eclipse menu. 2. Choose General - Existing Projects Into Workspace. 3. Click the Next button. Figure 24: Eclipse Import 46 PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures 4. Choose the Select root directory option. Figure 25: Select Root Directory 5. Click the Browse button and navigate to C:\CSI\PureWeb\SDK\Samples\Android. 6. Click the OK button. Figure 26: Browse for Project Folder Quick Start Guide: Android 47 Chapter 4: Common Procedures Common Procedures 7. In the Projects section, check the Asteroids, PureWeb, and Scribble projects. Figure 27: Select your Project 8. Click the Finish button to import the project into your workspace. Once the sample application is imported into your workspace, Eclipse will build the project automatically. You can always build the project by selecting Project | Build All from the Eclipse menu. Figure 28: Imported Projects Note: If build errors occur, select Project | Clean from the Main Menu. If the errors persist, restart Eclipse, and select Project | Clean again. End of procedure Next Steps • 48 Follow the steps in the “Creating a Sample Application Run Target” procedure. PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures Creating a Sample Application Run Target Purpose: To create a run target. Prerequisites • You must have completed the steps in the “Creating a Classpath Variable” procedure. • If you plan on deploying the application on an Android Virtual Device, you must have completed the steps in the “Creating an Android Virtual Device (AVD)” procedure. • You must have completed the steps in the “Importing the Sample Application into Eclipse” procedure. Start of procedure 1. Launch the PureWeb Apache Tomcat Server with the Start PureWeb desktop icon. 2. Select Run | Run Configurations from the Eclipse menu. Figure 29: Select Android Application Quick Start Guide: Android 49 Chapter 4: Common Procedures Common Procedures 3. Select Android Application and click the New icon to display the Run Configuration dialog. 4. In the Name field of the Android tab, Enter: • For ScribbleApp: ScribbleApp. • For AsteroidsApp: AsteroidsApp. Figure 30: Run Configuration 5. Click the Browse button to select your project: • For ScribbleApp: Scribble. • For AsteroidsApp: Asteroids. 6. Click the OK button. Figure 31: Select a Project 50 PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures 7. Choose the Launch Default Activity option, see Figure 30. 8. Select the Target tab. 9. Choose the Manual option in the Deployment Target Selection Mode section. This allows you to switch between the simulator and the actual device. Figure 32: Run Target 10. Click the Manager button to open the Android AVD Manager. Figure 33: Android AVD Manager Quick Start Guide: Android 51 Chapter 4: Common Procedures Common Procedures 11. Select the AVD2.1 as your preferred device. 12. Click the Apply button. Figure 34: Select AVD for Target 13. Click the Run button to display the simulator’s home screen. Figure 35: Device Home Screen End of procedure Next Steps • 52 Follow the steps in the “Configuring the Sample Application” procedure. PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures Configuring the Sample Application Purpose: To configure the sample application. Start of procedure Prerequisites • Launch the PureWeb Apache Tomcat Server with the Start PureWeb desktop icon. • Complete the procedures to build the application and start the device or simulator. Start of procedure The sample application icon will appear on the Menu page of the device. Figure 36: Device Menu Quick Start Guide: Android 53 Chapter 4: Common Procedures Common Procedures 1. Drag the sample application icon to the Home page of the device. Figure 37: Sample Application Icon on Home Screen 2. Click the sample application icon to display the application Login page. Figure 38: Sample Application Icon 3. Click the Menu button on the left side of the bottom of the page. Figure 39: Menu Button 54 PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures 4. Select the Settings option to display the Settings Page. From here you can: • set the ServerUrl for the service application. • set the User Name and Password for the server. • ensure security while collaborating. Figure 40: Setting Page 5. Select Server URL and change <hostname> to the name or IP of your server. Figure 41: Configuring the Server 6. Click OK and press the Back button to return to the Login page. End of procedure Next Steps • Quick Start Guide: Android Following the steps in the “Running the Sample Application” procedure. 55 Chapter 4: Common Procedures Common Procedures Running the Sample Application Purpose: To run the sample application. Prerequisites • Launch the PureWeb Apache Tomcat Server with the Start PureWeb desktop icon. • Complete the procedures to build the application and start the device or simulator. • Complete the procedure to configure the application. Start of procedure 1. Click the PureWeb icon to launch the application to display the Login page. 2. Enter admin/admin into the Username/Password fields. 3. Click Connect to launch the application. Figure 42: Login Page End of procedure Next Steps • 56 Examine the features of the sample application by reviewing the “Sample Functionality” section. PureWeb STK 3.1 Chapter 4: Common Procedures Common Procedures Debugging the AndroidClient Application Purpose: To debug the AndroidClient application. Prerequisites • To debug AndroidClient you must add the Dalvik Debug Monitor Server (DDMS) plugin to Eclipse. With it, you can view the messages produced by the emulator or device. Start of procedure 1. Review the request, response, and event information to the log file. For more information about Android debugging, see http://developer.android.com/guide/developing/debug-tasks.html. Note: The sample application is released as debuggable in the Manifest. Figure 43: Android Log End of procedure Quick Start Guide: Android 57 Supplements Related Documentation Resources The following resources provide additional information that is relevant to this software. Consult these additional resources as necessary. PureWeb® STK • PureWeb® Server Administration Guide, which provides information about the PureWeb® Server. • PureWeb® STK Installation Guide for Microsoft Windows, which provides detailed information on installing PureWeb® STK on a Microsoft Windows operating system. • PureWeb® Java Client STK API Reference, which describes the Java Client STK. • PureWeb® Java Server STK API Reference, which describes the Java Server STK. • PureWeb® Troubleshooting Guide, which describes solutions to common issue. • PureWeb® STK Release Notes. • PureWeb® STK Application Upgrading Notes. Quick Start Guide: Android 58 Document Conventions Document Conventions This document uses certain stylistic and typographical conventions— introduced here—that serve as shorthands for particular kinds of information. Document Version Number A version number appears at the bottom of the inside front cover of this document. Version numbers change as new information is added to this document. Here is a sample version number: PW3.0_Java_QSG_03-2011_v3.0.001.00 You will need this number when you are talking with Calgary Scientific Support about this product. Screen Captures Used in This Document Screen captures from the product graphical user interface (GUI), as used in this document, may sometimes contain minor spelling, capitalization, or grammatical errors. The text accompanying and explaining the screen captures corrects such errors except when such a correction would prevent you from installing, configuring, or successfully using the product. For example, if the name of an option contains a usage error, the name would be presented exactly as it appears in the product GUI; the error would not be corrected in any accompanying text. Type Styles Table 2 describes and illustrates the type conventions that are used in this document. Table 2: Type Styles Type Style Used For Examples Italic Please consult the Calgary Scientific Migration Guide for more information. • Document titles • Emphasis • Definitions of (or first references to) unfamiliar terms • Mathematical variables Do not use this value for this option. A customary and usual practice is one that is widely accepted and used within a particular industry or profession. Also used to indicate placeholder text within code samples or commands, in the special case The formula, x +1 = 7 where angle brackets are a required part of the where x stands for . . . syntax (see the note about angle brackets on page 60). Quick Start Guide: Android 59 Document Conventions Table 2: Type Styles (Continued) Type Style Used For Examples Monospace font All programming identifiers and GUI elements. This convention includes: Select the Show variables on screen check box. (Looks like teletype or • The names of directories, files, folders, configuration objects, paths, scripts, dialog boxes, options, fields, text and list boxes, operational modes, all buttons (including radio buttons), check boxes, commands, tabs, CTI events, and error messages. In the Operand text box, enter your formula. • The values of options. If you select true for the inbound-bsns-calls option, all established inbound calls on a local agent are considered business calls. typewriter text) • Logical arguments and command syntax. • Code samples. Also used for any text that users must manually enter during a configuration or installation procedure, or on a command line. Click OK to exit the Properties dialog box. Scribble service distributes the error messages in EventError events. Enter exit on the command line. A particular parameter or value that is optional smcp_server -host [/flags] Square brackets ([ ]) within a logical argument, a command, or some programming syntax. That is, the presence of the parameter or value is not required to resolve the argument, command, or block of code. The user decides whether to include this optional information. Angle brackets (< >) A placeholder for a value that the user must specify. This might be a DN or a port number specific to your enterprise. smcp_server -host <confighost> Note: In some cases, angle brackets are required characters in code syntax (for example, in XML schemas). In these cases, italic text is used for placeholder values. 60 PureWeb STK 3.1 Index Symbols F [] (square brackets). . . . . . . . . . . . . . 60 < > (angle brackets) . . . . . . . . . . . . . 60 font styles italic . . . . . . . . . . . . . . . . . . . . . 59 monospace . . . . . . . . . . . . . . . . . 60 A angle brackets . . . . . . . . . . . . . . . . 60 architecture. . . . . . . . . . . . . . . . . . 12 audience, for document . . . . . . . . . . . . 7 I intended audience . . . . . . . . . . . . . . . 7 italics . . . . . . . . . . . . . . . . . . . . . . 59 B M brackets angle. . . . . . . . . . . . . . . . . . . . . 60 square . . . . . . . . . . . . . . . . . . . . 60 methods connect . . . . . . . . . . . . . . . . . 17, 28 disconnect . . . . . . . . . . . . . 17, 20, 29 onCreate . . . . . . . . . . . . . . 17, 19, 28 onDestroy . . . . . . . . . . . . . . . . 17, 29 onOptionsItemSelected . . . . . . . . . 17, 29 onTouch . . . . . . . . . . . . . . . . . . . 30 queueKeyboardEvent . . . . . . . . . . 30, 31 monospace font . . . . . . . . . . . . . . . . 60 mouse events . . . . . . . . . . . . . . . . . 18 C class AsteroidsAppActivity. . . . . . . . . . . . . 28 client.AndroidUiDispatcher . . . . . . . 16, 28 pureweb.android.client.ui.View . . . . . 16, 28 ScribbleAppActivity . . . . . . . . . . . . . 17 ShareRequestCompleted . . . . . . . . . . 20 commenting on this document . . . . . . . . . 8 conventions in document . . . . . . . . . . . . . . . . . 59 type styles . . . . . . . . . . . . . . . . . . 59 D document audience. . . . . . . . . . conventions . . . . . . . . errors, commenting on . . reading recommendations. version number . . . . . . Quick Start Guide: Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 . 59 . 8 . 8 . 59 P prerequisites . . . . . . . . . . . . . . . . . .14 pureweb client . . . . . . . . . . . . . . . . . . . . 12 security . . . . . . . . . . . . . . . . . 11–12 server . . . . . . . . . . . . . . . . . . . . 12 service . . . . . . . . . . . . . . . . . . . 12 solution . . . . . . . . . . . . . . . . . . . 12 web technologies . . . . . . . . . . . . . . 11 R reading recommendations . . . . . . . . . . . 8 61 Index S sample applications asteroids. . . . . . . . . . . . . . . . . . . 14 scribble . . . . . . . . . . . . . . . . . . . 14 square brackets . . . . . . . . . . . . . . . 60 state view. . . . . . . . . . . . . . . . . . . 13 sub-class View . . . . . . . . . . . . . . . . . . . . . 18 support contacting . . . . . . . . . . . . . . . . . . 8 T tasks asteroids application tasks . . . . . . . . . 9 development tasks . . . . . . . . . . . . . 8 scribble application tasks . . . . . . . . . . 9 touches Single-finger drag . . . . . . . . . . . . . . 18 type styles conventions . . . . . . . . . . . . . . . . . 59 italic . . . . . . . . . . . . . . . . . . . . . 59 monospace . . . . . . . . . . . . . . . . . 60 typographical styles . . . . . . . . . . . . . 59 V version numbering, document . . . . . . . . 59 62 PureWeb STK 3.1