How to develop in Eclipse (Older than 1.4)
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.
2.Mobage.checkLoginStatus() checks the login status.
3.If the callback onLoginRequired is called, then call Mobage.showLoginDialog() to display the login dialog.
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 and root Activity.
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:
|you should call addPlatformListener() either in onCreate() and onRestart() (below), or only in onStart() (sample code in the SDK).|
|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.
A method which call People#getCurrentUser() can be implemented as follows:
- Added that Login Listener needs to be implemented on every Activity.
- Changing the position of calling registerTick() and adding a new member for PlatformListener
- Initial Release.