LINE SDK v4.0 for Android reference

Interfaces

InterfaceLineApiClient

The interface for accessing the Social API.

Package com.linecorp.linesdk.api

Methods

getCurrentAccessToken()
LineApiResponse<LineAccessToken> getCurrentAccessToken()

Gets the access token that the SDK is using for the user.

Return value

The LineApiResponse object. If the API call is successful, the LineApiResponse object contains the LineAccessToken object that contains the access token. If the API call fails, the payload of the LineApiResponse object is null.

getProfile()
LineApiResponse<LineProfile> getProfile()

Gets the profile information of the user.

Return value

The LineApiResponse object. If the API call is successful, the LineApiResponse object contains the LineProfile object that contains the user's profile information. If the API call fails, the payload of the LineApiResponse object is null.

logout()
LineApiResponse<?> logout()

Revokes the access token.

Return value

The LineApiResponse object containing information about the response.

refreshAccessToken()
LineApiResponse<LineAccessToken> refreshAccessToken()

Refreshes the access token that the SDK is using for the user.

Return value

The LineApiResponse object. If the API call is successful, the LineApiResponse object contains the LineAccessToken object that contains a new access token. If the API call fails, the payload of the LineApiResponse object is null.

verifyToken()
LineApiResponse<LineCredential> verifyToken()

Checks whether the access token that the SDK is using for the user is valid.

Return value

The LineApiResponse object. If the access token is valid, the LineApiResponse object contains a successful response and the LineCredential object that contains the access token. If the access token is invalid, the LineApiResponse object contains a failure response.

Classes

ClassLineApiError

Represents an error that is thrown by the Social API.

Package com.linecorp.linesdk
Extends Object
Implements Parcelable

Methods

getHttpResponseCode()
public int getHttpResponseCode()

Gets the response code associated with the API error.

Return value

The HTTP response code.

getMessage()
public String getMessage()

Gets the error message associated with the API error.

Return value

The error message associated with the API error.

ClassLineAccessToken

Represents an access token that is used to call the Social API.

Package com.linecorp.linesdk
Extends Object
Implements Parcelable

Methods

getAccessToken()
public String getAccessToken()

Gets the string representation of the access token.

Return value

The access token.

getEstimatedExpirationTimeMillis()
public long getEstimatedExpirationTimeMillis()

Gets the estimated time in UNIX time when the access token expires. The expiration time that is returned is not exact because it is calculated using time values that are cached on the client.

Return value

The estimated time in UNIX time when the access token expires.

getExpiresInMillis()
public long getExpiresInMillis()

Gets the amount of time in milliseconds until the access token expires.

Return value

The amount of time in milliseconds until the access token expires.

getIssuedClientTimeMillis()
public long getIssuedClientTimeMillis()

Gets the time in UNIX time when the access token information was last updated. This value is updated upon login, when the token is refreshed, and when the token is verified.

Return value

The time in UNIX time of when the access token information was last updated.

ClassLineApiClientBuilder

Represents a builder for creating LineApiClient objects with the desired settings.

Package com.linecorp.linesdk.api
Extends None
Implements None

Constructor

public LineApiClientBuilder(@NonNull Context context, int channelId) 
Parameters
Parameter Description
context Android context.
channelId Channel ID.

Methods

build()
public LineApiClient build()

Creates a LineApiClient instance.

Return value

The LineApiClient instance.

disableTokenAutoRefresh()
public LineApiClientBuilder disableTokenAutoRefresh()

Disables the SDK's feature to automatically refresh the access token.

Return value

The current LineApiClientBuilder instance.

ClassLineApiResponse

Represents a response from the Social API.

Package com.linecorp.linesdk
Extends Object
Implements None

Methods

getErrorData()
public LineApiError getErrorData()

Gets information about an API error that has occurred. This method should only be called if an API call has failed.

Return value

The LineApiError object that contains information about the error. If no error occurs, the LineApiError object does not contain any useful information.

getResponseCode()
public LineApiResponseCode getResponseCode()

Gets the response code that is returned.

Return value

The LineApiResponseCode object containing the HTTP status code which indicates whether the API call is successful.

getResponseData()
public R getResponseData()

Gets data that is associated with the response if it exists. If no data is associated with the response, it throws NoSuchElementException. You must check if the response succeeded by using the isSuccess() method before calling this method.

Return value

The response data in the same format as the generic type associated with the LineApiResponse class.

isNetworkError()
public boolean isNetworkError()

Checks whether the API call failed with a network error.

Return value

True if the API call fails with a network error; false otherwise.

isServerError()
public boolean isServerError()

Checks whether the API call failed with a server error.

Return value

True if the API call fails with a server error; false otherwise.

isSuccess()
public boolean isSuccess()

Checks whether the API call was successful.

Return value

True if the API call is successful; false otherwise.

ClassLineCredential

Represents credentials that are used to grant access to the Social API.

Package com.linecorp.linesdk
Extends Object
Implements Parcelable

Methods

getAccessToken()
public LineAccessToken getAccessToken()

Gets the access token.

Return value

The LineAccessToken object that contains the access token.

getPermission()
public List<String> getPermission()

Gets a list of permissions that the access token holds.

Return value

The string list of permission codes that are associated with the access token.

Permission code Description
P The token can be used to get the user's profile information.

ClassLineLoginApi

Represents the API to perform LINE login.

Package com.linecorp.linesdk.auth
Extends None
Implements None

Methods

getLoginIntent()
public static Intent getLoginIntent(Context context, int channelId)

Gets an intent for performing LINE login. If LINE is installed, the SDK logs in using app-to-app authentication through LINE. If LINE is not installed, the SDK uses the browser to log in.

Parameters
Parameter Description
context Android context.
channelId Channel ID.
Return value

The login intent that defaults to using LINE auto login.

getLoginIntentWithoutLineAppAuth()
public static Intent getLoginIntentWithoutLineAppAuth(Context context, int channelId)

Gets a login intent that only uses browser login.

Parameters
Parameter Description
context Android context.
channelId Channel ID.
Return value

The login intent that only uses browser login.

ClassLineLoginResult

Represents a login result that is returned from the LINE Platform.

Package com.linecorp.linesdk.auth
Extends Object
Implements Parcelable

Methods

isSuccess()

Checks whether the login was successful.

public boolean isSuccess() 
Return value

True if the login is successful; false otherwise.

getResponseCode()
public LineApiResponseCode getResponseCode()

Gets the response code that the login returned.

Return value

The LineApiResponseCode object with the response code that indicates whether the login was successful or not.

getLineProfile()
public LineProfile getLineProfile() 

Gets the user's profile information.

Return value

The LineProfile object with the user's LINE profile.

getLineCredential()
public LineCredential getLineCredential() 

Gets the user's credentials.

Return value

The LineCredential object with the user's authentication credentials.

getErrorData()
public getErrorData()

Gets information about a login error that has occurred. This method should only be called if the login has failed.

Return value

The LineApiError object that contains information about the error if a login error has occurred. Contains a response of 0 and a null string if no error occurs.

ClassLineProfile

Represents a user's LINE profile in the Social API.

Package: com.linecorp.linesdk
Extends: Object
Implements: Parcelable

Methods

getDisplayName()
public String getDisplayName()

Gets the user's display name.

Return value

The user's display name.

getPictureUrl()
public Uri getPictureUrl()

Gets the user's profile image URL.

Return value

The user's profile image URL.

getStatusMessage()
public String getStatusMessage()

Gets the user's status message.

Return value

The user's status message.

getUserId()
public String getUserId()

Gets the user's user ID.

Return value

The user's user ID.