GREE Platform Android SDK Ver. 3.0.0 α Developer's Guide · PDF file...

Click here to load reader

  • date post

    09-Jun-2020
  • Category

    Documents

  • view

    7
  • download

    0

Embed Size (px)

Transcript of GREE Platform Android SDK Ver. 3.0.0 α Developer's Guide · PDF file...

  • GREE Platform Android SDK Ver. 3.0.0 α Developer's Guide

    April 13, 2012 GREE, Inc.

    Copyright © 2012 GREE, Inc. All Rights Reserved.1

  • Version History Date Updates Changed Version

    2/22/2012 First edition - 1.0 4/13/2012 Alpha 2 release Information

    and formatting clean up

    1.1

    Copyright © 2012 GREE, Inc. All Rights Reserved.2

  • Copyright © 2012 GREE, Inc. All Rights Reserved.3

  • Table of Contents 1. GREE Platform Android SDK Outline

    1.1 Requirements 1.2 Distribution 1.3 Required Knowledge 1.4 Guideline Compliance

    2. Before Beginning Development

    2.1. Setting Up the GREE Sandbox

    3. Setting Up the Development Environment

    3.1. Importing the Library 3.1.1. Downloading the SDK 3.1.2. Adding Project and SDK to Eclipse 3.1.3. Creating Application Project 3.1.4. Referencing the GREE SDK from the Project

    3.2. Gadget XML

    4. Building a Sample App

    4.1. Setting up Initialization File 4.2. Handling Initialization 4.3. Setting Up AndroidManifest.xml

    5. Testing Created Apps

    5.1. Building a Developed App. 5.2. Running the App on the Simulator

    6. Calling Login/Logout Functions

    6.1. Login Processing 6.2. Logout Processing 6.3. Execution

    Appendix: Error Message List

    A1. OAuth A2. Initialization / Misc.

    Copyright © 2012 GREE, Inc. All Rights Reserved.4

  • 1. GREE Platform Android SDK Outline

    The GREE Platform Android SDK(SDK) allows programmers to implement

    the functions provided by the GREE social network within Android-compatible applications (apps).

    Please consult the GREE Platform Overview document included within the

    package for information on the functions this SDK offers.

    Copyright © 2012 GREE, Inc. All Rights Reserved.5

  • 1.1. Requirements Compatible devices

    OS Compatible with Android 2.2 and higher

    (*)API Level 8 and higher (*)Tablets not supported

    GREE Platform Android SDK version

    SDK Version GREE Platform Android SDK

    3.0.0 α Development environment

    開発環境 Version JDK Java SE Development Kit 6 Update 29 and

    higher Android SDK r14 and higher Eclipse 3.6 and higher

    1.2. Distribution The SDK is distributed as a class library (in the form of a Java source tree within

    an Android library project) which implements all provided functionality.

    1.3. Required Knowledge This document was written for developers with previous experience developing

    applications that use the Android SDK. For information on developing for Android, please consult the Android SDK reference provided by Google.

    1.4. Guideline Compliance

    GREE will provide a set of guidelines detailing how apps should use the GREE

    SDK. This document is not available during this release, and will be made available as soon as possible.

    Copyright © 2012 GREE, Inc. All Rights Reserved.6

  • 2. Before Beginning Development

    This SDK to projects under development allows for simple use of the functionality provided by the GREE Platform. A library of API functions is provided for apps, and calling these functions as necessary allows developers to use the data and UI provided by the GREE Platform.

    Please consult the GREE Platform Android SDK API Reference included with the

    SDK for details about the APIs provided with this SDK.

    2.1. Setting Up the GREE Sandbox The GREE Platform provides an environment, called the GREE sandbox, to test

    newly-developed apps. Please consult the supplemental document, Using the Sandbox for details.

    The following authentication keys are issued when registering an app for testing. These keys are required when implementing apps.

    Authentication Key Description

    CONSUMER_KEY The Consumer Key value issued by Developer Center (sandbox)

    CONSUMER_SECRET The Consumer Secret value issued by Developer Center (sandbox)

    APPLICATION_ID The App ID value issued by Developer Center (sandbox)

    Copyright © 2012 GREE, Inc. All Rights Reserved.7

  • 3. Setting Up the Development Environment

    This SDK assumes the use of a standard Eclipse-based Android app development environment. The information below assumes that Eclipse (English edition) and the Android SDK have already been set up.

    3.1. Importing the Library 3.1.1. Downloading the SDK

    Begin by downloading the GREE Platform Android SDK source code set from the

    GREE Developer Center. The method of source code distribution may change at any time without previous notice.

    3.1.2. Adding Project and SDK to Eclipse

    Go to [File -> Import] and select [General -> Existing Projects into Workspace].

    Import the "GreeSDK" , "signpost-commonshttp4" and "signpost-core" projects.

    Copyright © 2012 GREE, Inc. All Rights Reserved.8

  • 3.1.3. Creating Application Project Go to [File -> New -> Android Project] to create a new Android project. Select

    Android 2.3 or higher for the build target. Even if Android 2.3 is selected as the minimum SDK, the API level in the next screen can still be set to 7 to allow Android 2.1 devices to run the app.

    Set up the application info. We will set the name to GreeHelloSample. We will not

    create a test project for this app, so click on the "Finish" button.

    3.1.4. Referencing the GREE SDK from the Project

    Right-click on the project name in the Package Explorer and click on "Properties".

    Open the Android menu, then add the GreeSDK library.

    Copyright © 2012 GREE, Inc. All Rights Reserved.9

  • Next, in order to add needed external libraries, open the "Java Build Path" menu and include the "gson-2.0jar" file, in the "libs" folder inside the GreeSDK project. Click on "OK" and close the Properties dialog.

    3.2. Gadget XML

    Gadget XML allows for the retrieval of lifecycle event data via HTTP requests.

    Configuring Gadget XML is not necessary if lifecycle events are not being used. These documents are not yet available and will be provided as soon as possible.

    Copyright © 2012 GREE, Inc. All Rights Reserved.10

  • 4. Building a Sample App

    The following describes how to build a simple app that uses the functions provided in this SDK. After a GREE logo splash display, the app will display a sandbox authentication screen. After authentication is complete, the app will display "Hello World, GreeHelloSampleActivity".

    4.1. Setting Up Initialization File

    To begin with, we will set up a file in order to initialize the SDK. First, go to the "res" folder and create a folder named "xml".

    Next, we will create an XML configuration file within this folder. This file is named

    gree_platform_configuration.xml in this example.

    true GREEHelloSample GREE Hello Sample NNNN XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX sandbox

    ● Set "debug" to "true" to enable debugging output. ● "app_name" and "app_fullname" defines the name of the app. ● "app_id", "consumer_key" and "consumer_secret": Insert the app ID, consumerKey

    and consumerSecret here. -> These values are acquired when setting up the sandbox (section 2.2).

    ● "gree_environment": Set this to "sandbox" to enable access to the sandbox environment.

    Copyright © 2012 GREE, Inc. All Rights Reserved.11

  • 4.2. Handling Initialization

    In order to add the initialization code into the Application class, we will create an inheritor subclass, called GreeApplication here.

    package net.gree.sample.GreeHelloSample; import net.gree.asdk.api.GreePlatform; import android.app.Application; public class GreeApplication extends Application { @Override public void onCreate() { super.onCreate(); apiInit(); } public void apiInit() { GreePlatform.initialize(getApplicationContext(), R.xml.gree_platform_configuration); } }

    This GreePlatform.initialize function handles SDK initialization. The second argument

    defines the XML file resource previously created.

    4.3. Setting Up AndroidManifest.xml Next we will set up AndroidManifest.xml. Open the AndroidManifest.xml file for the app

    created. This file is on the app side. Do not edit the one inside the SDK itself.

    * "XXXX" is the app ID acquired when setting up the sandbox (section 2.2).

    We will add the activity set provided by the SDK. The app is set up to connect to the sandbox environment. Connecting to the GREE Platform, including the sandbox, requires login authentication from the user. The SDK uses OAuth 1.0(RFC5849) for authentication, and net.gree.asdk.core.auth.SetupActivity has been added.

    Copyright © 2012 GREE, Inc. All Rights Reserved.12

  • Within the "application" element, the GreeApplication class implemented in the GREE SDK, along with inheritor classes, are declared.

    The following sections are also recommended. ● "android:versionName" entry within "manifest" element

    -> android:versionName="N.N.N"

    ● SD card installation settings in "android:installLocation" entry within "manifest" element -> android:installLocation=[