If you think the Android project kakao-android-sdk-standalone listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/**
* Copyright 2014 Minyoung Jeong <kkungkkung@gmail.com>
* Copyright 2014 Kakao Corp.//fromwww.java2s.com
*
* Redistribution and modification in source or binary forms are not permitted without specific prior written permission.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.kakao;
import android.os.Message;
import com.kakao.helper.ServerProtocol;
import com.kakao.http.HttpRequestBuilder;
import com.kakao.http.HttpRequestTask;
import com.kakao.http.HttpResponseHandler;
import com.kakao.rest.APIHttpRequestTask;
import org.json.JSONException;
import java.util.Map;
/**
* UserManagement API ????? ????.
* @author MJ
*/publicclass UserManagement {
/**
* ?????? ??
* @param responseHandler me ?? ???? ?? handler
*/publicstaticvoid requestMe(final MeResponseCallback responseHandler) {
final String url = HttpRequestTask.createBaseURL(ServerProtocol.API_AUTHORITY, ServerProtocol.USER_ME_PATH);
request(responseHandler, url);
}
/**
* ???? ??
* @param responseHandler logout ?? ???? ?? handler
*/publicstaticvoid requestLogout(final LogoutResponseCallback responseHandler) {
final String url = HttpRequestTask.createBaseURL(ServerProtocol.API_AUTHORITY, ServerProtocol.USER_LOGOUT_PATH);
request(responseHandler, url);
}
/**
* Unlink ??
* @param responseHandler unlink ?? ???? ?? handler
*/publicstaticvoid requestUnlink(final UnlinkResponseCallback responseHandler) {
final String url = HttpRequestTask.createBaseURL(ServerProtocol.API_AUTHORITY, ServerProtocol.USER_UNLINK_PATH);
request(responseHandler, url);
}
/**
* ?? ??
* @param responseHandler signup ?? ???? ?? handler
* @param properties ??? ???? ???? ??
*/publicstaticvoid requestSignup(final SignupResponseCallback responseHandler, final Map properties) {
final String url = HttpRequestTask.createBaseURL(ServerProtocol.API_AUTHORITY, ServerProtocol.USER_SIGNUP_PATH);
request(responseHandler, url, properties);
}
/**
* ?????? ?? ??
* @param responseHandler updateProfile ?? ???? ?? handler
* @param properties ??? ???? ??
*/publicstaticvoid requestUpdateProfile(final UpdateProfileResponseCallback responseHandler, final Map properties) {
final String url = HttpRequestTask.createBaseURL(ServerProtocol.API_AUTHORITY, ServerProtocol.USER_UPDATE_PROFILE_PATH);
request(responseHandler, url, properties);
}
privatestaticvoid request(final HttpResponseHandler<Map> responseHandler, final String url) {
final HttpRequestBuilder requestBuilder = HttpRequestBuilder.get(url);
APIHttpRequestTask.addCommon(requestBuilder);
APIHttpRequestTask.checkSessionAndExecute(new APIHttpRequestTask<Map>(requestBuilder.build(), responseHandler, Map.class), responseHandler);
}
privatestaticvoid request(final HttpResponseHandler<Map> responseHandler, final String url, final Map properties) {
final HttpRequestBuilder requestBuilder = HttpRequestBuilder.get(url);
APIHttpRequestTask.addCommon(requestBuilder);
try {
APIHttpRequestTask.addQueryParam(requestBuilder, ServerProtocol.PROPERTIES_KEY, properties);
APIHttpRequestTask.checkSessionAndExecute(new APIHttpRequestTask<Map>(requestBuilder.build(), responseHandler, Map.class), responseHandler);
} catch (JSONException e) {
responseHandler.sendMessage(Message.obtain(responseHandler, HttpRequestTask.ERROR, 0, 0,
new APIErrorResult(requestBuilder.build().getUrl(), e.getMessage())));
}
}
}