How to Develop in Eclipse (version 1.4 or later)
This chapter explains how to create a new application by using the Mobage Native SDK. The application launch sequence of the Mobage Native SDK is as follows.
1.Mobage.initialize() performs the initialization process.
After Mobage.initialize, call Mobage.registerTick() only once within your application.
2.Mobage.checkLoginStatus() checks the login status.
3.If the callback onLoginRequired and onSplashComplete is called, then call Mobage.showLoginDialog() to display the login dialog.
|Only call showLoginDialog when both onLoginRequired and onSplashComplete have been called on initialization.|
Please create a new Android project, and implement the following class HelloMobageActivity, which inherits from the class Activity.
Immediately after the launch of your application, an initialization method is required to be invoked. The arguments of the method are: region type, environment type, consumerKey, consumerSecret, application ID, root Activity and splash screen on/off.
Note that consumerKey and consumerSecret are issued when you register your application at the Mobage developer site. Please specify SDK Consumer Key (for development) and SDK Consumer Secret (for development) in the Android application settings tab on the developer site as the arguments of the initialization method.
In order to check the login status, you need to call addPlatformListener() to register a login listener, and to call checkLoginStatus(). Make sure to implement login listener to every Activity.
The implementation of the login listener can be as follows:
Please choose one of the implementations of (1) calling in onCreate and onRestart like above and (2) calling only in onStart.
|Since the login listener is removed automatically when onStop is called, need not remove it explicitly.|
The Mobage Native SDK handles events asynchronously. A thread, which invoked the listener registration method, receives the results of the event handlings. Thus, you need to call the following method to register the Mobage#tick() method into Timer.
By using the Mobage Native SDK, Your application needs to call Mobage API corresponding to the lifecycle method of each Activity. Not only Main Activity but all the Activities need to implement like this.
A method which call People#getCurrentUser() can be implemented as follows:
- Argument boolean for splash screen has been added to the initialize method from Mobage SDK 1.4.7
- Added to call both onLoginRequired and onSplashComplete before calling showLoginDialog
- Added Login Listener needs to be implemented on every Activity.
- Initial Release.