Login Button Register Callback Not Working Android Updated FREE
Login Button Register Callback Not Working Android
# Integrating LINE Login with your Android app
This topic explains how to implement LINE Login by integrating the LINE SDK for Android with your existing Android app. To meet what LINE Login can do, read Trying the starter app and try the LINE Login starter app for Android.
# Prerequisites
To build and use the LINE SDK for Android, you demand:
- A provider and a LINE Login aqueduct. You can create both in the LINE Developers Console.
- To prepare
minSdkVersion
to 17 or higher (Android four.2 or later).
Resource naming conflicts
Don't use resource IDs that start with linesdk_
as this may cause conflicts with the resources in the SDK.
# Upgrading from before SDK versions
If you're upgrading from LINE SDK v4.x or earlier, it helps to know that the current version has these major differences:
- When starting login, you must specify Scopes to determine which user information your app tin admission.
- If you specify the
OPENID_CONNECT
scope during login, you tin can become an ID token to securely verify the user's identity.
# Add LINE SDK dependency
To integrate LINE SDK for Android, import the required library to your project and configure the Android manifest file of your project by following the steps below.
# Import the library into your projection
Add together LINE SDK dependency in your module-level build.gradle
file.
# Add Android compilation options
Enable Coffee 1.8 support. In the aforementioned build.gradle
file as to a higher place, add together:
# Setting the Android manifest file
To specify that your app requires Internet access, add the Internet
permission to your AndroidManifest.xml
file.
Note
Make sure the launch style of the activity that is making the login call is not gear up to singleInstance
as that may forestall the activity from receiving the onActivityResult
callback.
# Linking your app to your channel
Linking your app to a LINE Login channel, enable Mobile app on the LINE Login tab of your channel settings on the LINE Developers Console and complete these fields.
- Package names: Required. Application'southward package name used to launch the Google Play shop.
- Parcel signatures: Optional. Yous can fix multiple signatures by entering each 1 on a new line.
- Android URL scheme: Optional. Custom URL scheme used to launch your app.
# Adding the LINE Login button
To allow the user log in to your Android app, yous tin can create a LINE-branded login push to take the user through the authentication and authorization process.
There are 2 ways to add a login button:
- Use the LINE SDK'due south built-in login push
- Use a customized login push
# Use the LINE SDK's built-in login push
The LINE SDK provides a pre-defined login button. You lot can add together a login button to the user interface of your app to provide your users with a quick way to log in every bit below:
-
Add the login button in your layout XML file.
-
Find the view in your activeness or fragment, fix necessary parameters, and assign a listener to information technology.
# Apply a customized login button
Instead of using the default login button, you lot can also customize your user interface and login procedure with your own code.
# Download and add together the images to your projection
The LINE Login push button paradigm set includes images for iOS, Android and desktop applications. The image set up for Android includes images for multiple screen densities and button states. In this guide, we'll use the "base of operations" and "pressed" login push images in the Android folder.
- Download and extract the LINE Login push images (opens new window) .
- Add the "base" and "pressed" login push images to the
drawable
folder for each screen density.
# Configure the images
Before y'all can use the images, yous'll demand to add the login button text that you want to employ. See LINE Login button pattern guidelines for the recommended login push button text for different languages. You'll also need to define stretchable regions of the image to add the push text without distorting the LINE icon.
- Create 9-patch files (opens new window) for each image and define the stretchable regions for the login push text.
- Add the push to the login screen of your app every bit a clickable text view with your desired login push button text.
- Add selector XML files in your drawable folders to define the epitome which corresponds to the country of the text view.
# Starting the login action
When a user taps the login button, your app calls getLoginIntent()
to get the login intent and start the login activeness. The context and the aqueduct ID must be passed into this method. If LINE is installed on the device, LINE is opened to perform login without request for the user's LINE credentials. If LINE is not installed, users are redirected to the LINE Login screen in a browser to enter their LINE credentials (electronic mail address and password).
- Set an on-click listener to heed for when the button is tapped.
- In the
onClick
callback, call thegetLoginIntent()
method inLineLoginApi
to get the login intent to start the login activity. - Start the authentication process by calling
startActivityForResult()
and passing the login intent and request code as parameters. The request lawmaking is an integer that is used to place the request.
The post-obit is an example of how to start the activity to log in the user when the user taps the login button.
Note
If y'all do non want to use app-to-app login and instead have the user log in via the LINE Login screen in a browser, use the getLoginIntentWithoutLineAppAuth()
method.
# Handling the login result
Later on the user has logged in, the login result is returned in the activity's onActivityResult()
method. Your application must override this method to handle the login result.
Use the getResponseCode()
method of the LineLoginResult
object to make up one's mind if the login was successful. If getResponseCode()
returns SUCCESS
, the login was successful. Whatsoever other value indicates a failure. See Handling errors to make up one's mind the blazon of error that occurred.
The following shows an instance of how the login issue can be handled by your app.
# Become the access token
The login event contains a LineCredential()
object which contains the user'south access token. As shown in the example above, y'all tin recollect the access token using the following lawmaking.
# Become user profile immediately after login
The LINE SDK automatically gets a user's contour information upon logging in. The user'south profile information consists of the display name, user ID, status message, and profile media URL. Access this information by calling the getLineProfile()
method in the LineLoginResult
object. The post-obit lawmaking snippet from the case to a higher place demonstrates how to get a user's profile data from the login upshot and pass it into an intent.
The user ID is only unique to an individual provider. The same LINE user will have a different user ID for dissimilar providers. Avoid using the user ID to place users across different providers.
# Using user data on your server
User impersonation
Practise non trust user IDs, or other information bachelor in the LineProfile
object, when sent by a customer to your backend server. A malicious client tin send an arbitrary user ID or malformed information to your server to impersonate a user.
Instead, the client should send the server an access token, and the server should apply the token to retrieve user information.
Typically, a back-finish server verifies a user's identity based on a user ID, display proper name, or some other LINE business relationship holding. But instead of sending that data from the client to your server directly, the client should send an access token. The server should so use this to securely verify the user's identity against LINE's server.
Acquire more about access tokens from Get the access token.
Acquire more virtually what APIs to call from your backend on these pages:
- Verify access token validity
- Get user contour
# Using the LineApiClient
interface
Use the SDK by calling the methods of the LineApiClient
interface. To do this, create a static variable of a lineApiClient
object and initialize the variable.
-
Create a static variable of the object to telephone call various methods.
-
Initialize the
lineApiClient
variable on your activity'sonCreate()
method as shown below. The channel ID and the context are required for initialization.
Note
All methods in the LINE SDK for Android perform network operations and volition cause NetworkOnMainThreadExceptions
if called on the principal thread. To avoid this issue, call the methods using AsyncTask
.
Login Button Register Callback Not Working Android
DOWNLOAD HERE
Source: https://developers.line.biz/en/docs/android-sdk/integrate-line-login/
Posted by: greenefirldetel.blogspot.com
Comments
Post a Comment