Developer Guide: Android Object API Ap ... 2013/04/14 آ  Developer Guide: Android Object API Applications

  • View
    0

  • Download
    0

Embed Size (px)

Text of Developer Guide: Android Object API Ap ... 2013/04/14 آ  Developer Guide: Android Object API...

  • Developer Guide: Android Object API Applications

    SAP Mobile Platform 2.3 SP03

  • DOCUMENT ID: DC01908-01-0233-01 LAST REVISED: September 2013 Copyright © 2013 by Sybase, Inc. All rights reserved. This publication pertains to Sybase software and to any subsequent release until otherwise indicated in new editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished under a license agreement, and it may be used or copied only in accordance with the terms of that agreement. Upgrades are provided only at regularly scheduled software release dates. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of Sybase, Inc. Sybase trademarks can be viewed at the Sybase trademarks page at http://www.sybase.com/detail?id=1011207. Sybase and the marks listed are trademarks of Sybase, Inc. ® indicates registration in the United States of America. SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. Java and all Java-based marks are trademarks or registered trademarks of Oracle and/or its affiliates in the U.S. and other countries. Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. All other company and product names mentioned may be trademarks of the respective companies with which they are associated. Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies. Sybase, Inc., One Sybase Drive, Dublin, CA 94568.

    http://www.sybase.com/detail?id=1011207

  • Contents

    Getting Started with Android Development ........................1 Object API Applications ..................................................1 Best Uses for Object API Applications ............................2

    Cache Synchronization ..........................................2 Client Runtime Architecture ...................................3

    Documentation Roadmap for SAP Mobile Platform ........4 Development Task Flow for Object API Applications .........5

    Installing the Android Development Environment ...........6 Installing the Android SDK .....................................7 Installing ADT in SAP Mobile WorkSpace .............7 Installing X.509 Certificates on Android Devices

    and Emulators ..................................................7 Generating Java Object API Code ..................................8

    Generating Java Object API Code Using SAP Mobile WorkSpace ............................................9

    Generating Java Object API Code Using the Code Generation Utility ...................................13

    Generated Code Location and Contents .............14 Validating Generated Code ..................................14

    Creating a Project .........................................................15 Creating a Project in SAP Mobile WorkSpace .....15 Downloading the Latest Afaria Libraries ..............18 Importing Libraries and Code ..............................18

    Development Task Flow for DOE-based Object API Applications .....................................................................19

    Installing the Android Development Environment .........20 Installing the Android SDK ...................................20 Installing X.509 Certificates on Android Devices

    and Emulators ................................................21 Generating Java Object API Code ................................22

    Generated Code Location and Contents .............23

    Developer Guide: Android Object API Applications iii

  • Creating a Project .........................................................23 Creating a Project in SAP Mobile WorkSpace .....24 Downloading the Latest Afaria Libraries ..............26 Importing Libraries and Code ..............................26

    Developing the Application Using the Object API ............29 Initializing an Application ..............................................29

    Initially Starting an Application .............................29 Subsequently Starting an Application ..................46

    Accessing MBO Data ....................................................47 Object Queries .....................................................47 Dynamic Queries .................................................48 MBOs with Complex Types ..................................49 Relationships .......................................................49

    Manipulating Data .........................................................50 Creating, Updating, and Deleting MBO Records

    .........................................................................51 Other Operations .................................................52 Using submitPending and

    submitPendingOperations ...............................53 Shutting Down the Application ......................................54

    Closing Connections ............................................54 Debugging Runtime Errors and Performance Analysis

    ..................................................................................54 End to End Tracing ..............................................54 Tracking KPI .........................................................56

    Uninstalling the Application ...........................................58 Deleting the Database and Unregistering the

    Application .......................................................58 Recovering From SAP Mobile Server Failures .............58

    Testing Applications ............................................................71 Testing an Application Using a Emulator ......................71 Client-Side Debugging ..................................................72 Server-Side Debugging ................................................73 Improve Synchronization Performance by Reducing

    the Log Record Size .................................................74

    Contents

    iv SAP Mobile Platform

  • Determining the Log Record Size ........................75 Reducing the Log Record Size ............................78

    Localizing Applications .......................................................81 Packaging Applications ......................................................83

    Signing ..........................................................................83 Client Object API Usage ......................................................85

    Client Object API Reference .........................................85 Application APIs ............................................................85

    Application ...........................................................86 ConnectionProperties ..........................................99 ApplicationSettings ............................................108 ConnectionPropertyType ...................................111

    Afaria APIs ..................................................................117 Using Afaria to Provision Configuration Data ....117 Using Certificates from Afaria for Authentication

    .......................................................................119 Connection APIs .........................................................121

    ConnectionProfile ..............................................121 Set Database File Property ...............................123

    Synchronization Profile ...............................................124 Connect the Data Synchronization Channel

    Through a Relay Server ................................124 Asynchronous Operation Replay .......................125

    Authentication APIs ....................................................126 Logging In ..........................................................126 Sample Code: Setting Up Login Credentials .....126 Sample Code: Mutual Authentication ................127 Single Sign-On With X.509 Certificate Related

    Object API .....................................................128 Personalization APIs ...................................................129

    Type of Personalization Keys .............................129 Getting and Setting Personalization Key Values

    .......................................................................130 Synchronization APIs ..................................................131

    Managing Synchronization Parameters .............131

    Contents

    Developer Guide: Android Object API Applications v

  • Performing Mobile Business Object Synchronization .............................................131

    Message-Based Synchronization APIs .............132 Push Synchronization Applications ....................137 Retrieving Information about Synchronization

    Groups ...........................................................138 Resumable Synchronization ..............................138

    Log Record APIs .........................................................142 LogRecord API ..................................................143 Logger APIs .......................................................145

    Change Log API .........................................................145 getEntityType .....................................................145 getOperationType ..............................................146 getRootEntityType ..............................................146 getRootSurrogateKey .......