Skip to content

[EN] Callback Listener

ch.yang edited this page Aug 4, 2016 · 1 revision

Callback Listeners

You can handle events occurred in the NAVER Cafe SDK by adding callback listeners.

The callback listener has been supported since 1.4.0 of the NAVER Cafe SDK.

OnSdkStartedListener

OnSdkStartedListener is a callback listener that handles an event occurred when the NAVER Cafe SDK starts.

Add OnSdkStartedListener in the setOnSdkStartedListener() method to implement tasks to be handled.

public static void setOnSdkStartedListener(Glink.OnSdkStartedListener onSdkStartedListener);

The following code shows an example of how to implement this listener.

   // Add OnSdkStartedListener.
    Glink.setOnSdkStartedListener(new Glink.OnSdkStartedListener() {
      @Override public void onSdkStarted() {
        Toast.makeText(MainActivity.this, "Starting the NAVER Cafe SDK", Toast.LENGTH_LONG).show();
      }
    });

OnSdkStoppedListener

OnSdkStoppedListener is a callback listener that handles an event occurred when the NAVER Cafe SDK stops.

Add OnSdkStoppedListener in the setOnSdkStoppedListener() method to implement tasks to be handled.

public static void setOnSdkStoppedListener(Glink.OnSdkStoppedListener onSdkStoppedListener);

The following code shows an example of how to implement this listener.

   // Add OnSdkStoppedListener.
    Glink.setOnSdkStoppedListener(new Glink.OnSdkStoppedListener() {
      @Override public void onSdkStopped() {
        Toast.makeText(MainActivity.this, "Stopping the NAVER Cafe SDK", Toast.LENGTH_LONG).show();
      }
    });

onClickAppSchemeBannerListener

onClickAppSchemeBannerListener is a callback listener that handles an event occurred when a gamer taps a banner image linking to an app scheme.

For more information on app schemes, see "App Scheme".

Add OnClickAppSchemeBannerListener in the setOnClickAppSchemeBannerListener() method to implement tasks to be handled.

public static void setOnClickAppSchemeBannerListener( OnClickAppSchemeBannerListener onClickAppSchemeBannerListener);

The following code shows an example of how to implement this listener.

public static void setOnClickAppSchemeBannerListener( OnClickAppSchemeBannerListener onClickAppSchemeBannerListener)

   // Add app scheme listener.
    Glink.setOnClickAppSchemeBannerListener(new Glink.OnClickAppSchemeBannerListener() {
      @Override public void onClickAppSchemeBanner(String appScheme) {
        // The NAVER Cafe SDK passes the appScheme string added in the Community Setting page.
        // Write code to handle each appScheme.
        Toast.makeText(MainActivity.this, appScheme, Toast.LENGTH_LONG).show();
      }
    });

OnJoinedListener

OnJoinedListener is a callback listener that handles an event occurred when a gamer joins the NAVER Cafe community through the NAVER Cafe SDK.

Add onJoinedListener in the setOnJoinedListener() method to implement tasks to be handled.

public static void setOnJoinedListener(Glink.OnJoinedListener onJoinedListener);

The following code shows an example of how to implement this listener.

   // Add OnJoinedListener.
    Glink.setOnJoinedListener(new Glink.OnJoinedListener() {
      @Override public void onJoined() {
        Toast.makeText(MainActivity.this, "You have joined.", Toast.LENGTH_SHORT).show();
      }
    });

OnPostedArticleListener

OnPostedArticleListener is a callback listener that handles an event occurred when a user adds a post within the NAVER Cafe SDK.

Add OnPostedArticleListener in the setOnPostedArticleListener() method to implement tasks to be handled.

public static void setOnPostedArticleListener( Glink.OnPostedArticleListener onPostedArticleListener);

The following code shows an example of how to implement this listener.

   // Add OnPostedArticleListener.
    Glink.setOnPostedArticleListener(new Glink.OnPostedArticleListener() {
      @Override public void onPostedArticle(int menuId, int imageCount, int videoCount) {
        String message = String.format("A post is added. (from listener, menu: %d)", menuId);
        Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
      }
    });

OnPostedCommentListener

OnPostedCommentListener is a callback listener that handles an event occurred when a user adds a comment to a post within the NAVER Cafe SDK.

This listener has been supported since 1.7.0 of the NAVER Cafe SDK.

Add OnPostedCommentListener in the setOnPostedCommentListener() method to implement tasks to be handled.

public static void setOnPostedCommentListener( Glink.OnPostedCommentListener onPostedCommentListener);

The following code shows an example of how to implement this listener.

   // Add OnPostedCommentListener.
    Glink.setOnPostedCommentListener(new Glink.OnPostedCommentListener() {
      @Override public void onPostedComment(int articleId) {
        String message = String.format("A comment is added. (from listener, post: %d)", articleId);
        Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
      }
    });

OnVotedListener

OnVotedListener is a callback listener that handles an event occurred when a user has voted on a post within the NAVER Cafe SDK.

This listener has been supported since 1.6.0 of the NAVER Cafe SDK.

Add OnVotedListener in the setOnVotedListener() method to implement tasks to be handled.

public static void setOnVotedListener(Glink.OnVotedListener listener);

The following code shows an example of how to implement this listener.

   // Add OnVotedListener.
    Glink.setOnVotedListener(new Glink.OnVotedListener() {
      @Override public void onVoted(int articleId) {
        String message = String.format("Vote is completed. (from listener, post: %d)", articleId);
        Toast.makeText(MainActivity.this, message, Toast.LENGTH_SHORT).show();
      }
    });

OnWidgetScreenshotClickListener

OnWidgetScreenshotClickListener is a callback listener that handles an event occurred when a user taps a screen capture button within the Cafe widget. For more information on the screen capture button of the Cafe widget, see "Widget".

This listener has been supported since 1.7.0 of the NAVER Cafe SDK.

Add OnWidgetScreenshotClickListener in the setOnWidgetScreenshotClickListener() method to implement tasks to be handled.

public static void setOnWidgetScreenshotClickListener(Glink.OnWidgetScreenshotClickListener onWidgetScreenshotClickListener);

The following code shows an example of how to implement this listener. The functionality of screen capture must be implemented in the callback listener in order to make the screen capture button enabled.

  // Add OnWidgetScreenshotClickListener.
  Glink.setOnWidgetScreenshotClickListener(new Glink.OnWidgetScreenshotClickListener() {
      @Override public void onScreenshotClick() {
        //TODO: Capture screen and execute the NAVER Cafe SDK. (sudo code below)
        String uri = screenCapture();
        Glink.startImageWrite(getActivity(), "title", uri);
      }
    });

onRecordFinishListener

onRecordFinishListener is a callback listener that handles an event occurred when video recording has completed within the NAVER Cafe SDK.

Add OnRecordFinishListener in the setOnRecordFinishListener() method to implement tasks to be handled.

public static void setOnRecordFinishListener(OnRecordFinishListener onRecordFinishListener);

The following code shows an example of how to implement this listener.

  // Add onRecordFinishListener.
  Glink.setOnRecordFinishListener(new Glink.OnRecordFinishListener() {
      @Override public void onRecordFinished(String uri) {
        Glink.startVideoWrite(MainActivity.this, -1, "title", "subject", uri);
      }
    });

Other NAVER CAFE SDK Documents.

Unity

Unreal

Cocos-2dx

iOS

Clone this wiki locally