Android
Quick Start
Download the Latest Version
Run Sample Project
The method to run NaverGame SDK’s sample project in Android studio is as follows.
Using Android Studio, open the project within the sample/navergame-sdk-sample-android-studio folder.
Build the project.
Confirm that the SDK is running normally in the application.
NaverGame SDK Environment Settings
1. App Manifest Settings
Add the access permissions and activity to the AndroidManifest.xml file as is shown in the following.
1.1 NaverGame SDK Access Permission
Add the access permission required for NaverGame SDK.
2. Gradle Settings
Set at build.gradle, in measures of modules that will be using the SDK.
2.1 PlugIn Settings
NaverGameSdk uses kotlin.
Declare the kotlin plugin as shown in the following in the declaration section for plugins.
2.2 Library Addition
Download the latest library file from https://github.com/naver/navergame-sdk-android/releases
Create the libs folder within the project folder and paste the downloaded navergame-sdk-gradle-XXX.aar file.
The aar library for Android Studio is the version that manages external libraries to prevent a collision in dependency.
The libs folder structure may differ depending on the gradle version and the project settings, but normally its located in the same folder as the src.
2.3 Dependency Settings
Add the library used by the NaverGameSdk.
Add the library in the Dependency declaration section as shown in the following.
Please maintain NaverGameSDK’s version name since the glide library and the retrofit library are not compatible with other versions.
In case the glide and the retrofit library conflict with other libraries that are being used, the dependency can be maintained by dividing up the project by libraries.
3. ProGuard Settings
When using the NaverGame SDK, if minifyEnabled is set to true, an option that excludes the ProGuard must be added.
Open the proguard-rules.pro file and input the following content.
Because ProGuard declarations do not cause problems even if they are duplicated, it can simply be pasted in.
The following file can be downloaded from NaverGameSDK Github.
4. initialize
initialize the NaverGame SDK such as the following according to the languages supported by NaverGame SDK.
4.1 NaverGame SDK initialization
During the initializing of Navergame SDK, the options have to be set as shown in the following, and the init() method has to be called.
ClientId: The Client Id received after registering the application at developers center upon logging in with a Naver Id.
ClientSecret: The client secret received after registering the application at developers center upon logging in with a Naver Id.
LoungeId: The Lounge Id received after requesting for an official lounge.
5. Start NaverGame SDK
Run NaverGame SDK after completing the initialization.
5.1 startHome() method
The startHome() method is the method used to start the home banner.
Using NaverGameSDK
initModule() method
initialize the NaverGame SDK
The following case is a demonstration of the implementation of the initModule() method.
finishSdk() method
The finishSdk() method is the method that terminates NaverGameSDK. It is called in when the sdk has to be terminated under certain circumstances. For example, the finishSdk() method has to be called to close the sdk when running the in-game menu code that is delivered through the callback of GLinkDelegate.
startHome() method
Run the home banner.
The following case is a demonstration of the implementation of the startHome() method.
startSorry() method
Exclusively posts a common notification or a notification for maintenance
The following case demonstrates the implementation of the startSorry() method.
startBoard(int boardId) method
This is the method that immediately runs the specific bulletin board registered on the Official Lounge Maintenance Page > SDK Maintenance>Bulletin Board Maintenance pages.
The following example is a demonstration of the implementation of the executeBoard() method.
startFeed(long feedId, bool isTempFeedId) method
A method that immediately runs with the number of the registered post. Under the case of a scheduled notification post that has been scheduled through scheduled exposure, the number of the scheduled post must be inputted into FeedId and IsTempFeedId must be inputted as True. Before the scheduled post is posted, running the method does not lead to the exposure of the post.
FeedId: The number of the notification post or the scheduled notification post.
IsTempFeedId: False if the FeedId is a notification post and true if FeedId is a scheduled notification post.
The following example is a demonstration of the implementation of the executeFeed() method.
writeFeed(int boardId , string title, string content, string imageUri) method
This method runs the writer page. BoardId is the board number, Title is the title of the writing, Text is the content of the writing, and ImageFilePath is the path of the attached image. Only one image may be attached.
Not all parameters are necessary. If entered, they will be set in the writer page in advance.
boardId: This is the board number. This can be found in the URL shown while accessing the board through the web, in the form of https://game.naver.com/lounge/{loungeId}/board/{boardId}.
title: This is the title of the writing.
text: This is the text to be added to the main body.
imageFilePath: This is the LocalPath of the image to be attached. In Android, there is a process of obtaining image rights, so if this value is manually entered, it needs to be checked thoroughly.
The following example is a demonstration of the implementation of the writeFeed() method.
enableScreenShotDetector(bool enabled) method
This method shows a button for writing by detecting when a user has taken a screenshot. When not summoned, the base value is ON (true).
If enabled: true, writing button appears when a screenshot is captured.
The following example is a demonstration of the implementation of the enableScreenShotDetector() method.
putGameId(string gameId) method
This method syncs with NAVER Login and matches the user and their NAVER ID. This can be used to confirm the game ID of users that win event draws through posts and comments.
This called be called at any point after the init function is called.
gameId: Input an identifiable game ID. Only one game ID is saved for one NAVER ID.
The following example is a demonstration of the implementation of the putGameId() method.
getCountryCode() method
Obtain the countryCode of the Android device.
The countryCode is the country code (ISO 3166-1 alpha-2) composed of two alphabets. This enables branch processing by countries within the codes. The notable country codes are as shown in the following. Refer to the link for other country codes.
Country Code
Country
CN
China
JP
Japan
KR
Republic of Korea
TH
Thailand
US
United States of America
The following is an example of using the getCountryCode() method to reset the SDK exclusively for Korea.
NNGCallbackListener Callback Listener
In the case that a specific event occurs within the Sdk, the delivery is made using the callback listener. The registration method is as follows.
onSdkDidLoaded() method
Occurs when the NaverGameSdk is running.
onSdkDidLoaded() method
Occurs when NaverGameSdk is terminated.
onCallInGameMenuCode() method
Occurs when the in-game menu code has to be run in NaverGameSdk. Used when an 'In-Game Menu’ has been registered on the banners of Official Lounge Maintenance> Page >SDK Maintenance>Banner Maintenance pages. Depending on the Android and iOS platforms, the registered values are delivered independently, so if different values have been inputted, they must be processed independently.
Horizontal Mode, Vertical Mode
Naver Game SDK supports both horizontal and vertical modes. Under Android environments, the horizontal mode and the vertical mode is applied automatically according to the screen’s horizontal and vertical orientation without the need of additional settings.
Last updated