Android SDK Setup

From Social ID Developers
(Difference between revisions)
Jump to: navigation, search
(Created page with "= Existing Project = == Download the SDK == Import the zip file's contents into your existing Android project by extracting it into your "libs" folder. If your project does ...")
 
m (Android Manifest)
 
(22 intermediate revisions by 5 users not shown)
Line 1: Line 1:
= Existing Project =
+
= Configure CoffeeBean SDK in your app =
  
== Download the SDK ==
+
You'll need 3 variables to configure the SDK:
  
Import the zip file's contents into your existing Android project by extracting it into your "libs" folder. If your project does not already have a "libs" folder, create one at the root of the project by right-clicking the project and choosing "New" and then "Folder."
+
* SENDER_ID: Set up a project on Google Developers Console - https://console.developers.google.com/project. Get your project number. This will be used as the SENDER_ID in the SDK.
 +
* LOGIN_APP_ID: Set up a CoffeeBean LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app. This will be used as the LOGIN_APP_ID in the SDK.
 +
* LOGIN_APP_CLIENT_SECRET: The client secret can be found on the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis. This will be used as the LOGIN_APP_CLIENT_SECRET in the SDK.
  
[http://www.example.com Download the SDK]
+
== Download the SDK ==
  
== Get your SocialID data ==
+
[[Android_SDK_Download|Download the SDK]]
  
You'll need 5 variables to configure the SDK:
+
Import the AAR file into your existing AndroidStudio as a new module and update your project and app .gradle files to include the new module.
  
* SENDER_ID: Set up a project on Google Developers Console - https://cloud.google.com/console/project. Get your project number. This will be used as the SENDER_ID in the SDK.
+
Project ''settings.gradle'' file:
* LOGIN_APP_API_KEY: Set up an SocialId LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app. This will be used as the LOGIN_APP_API_KEY in the SDK.
+
* LOGIN_APP_API_SECRET: The secret can be found at the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis. This will be used as the LOGIN_APP_API_SECRET in the SDK.
+
* API_KEY: The API_KEY can be found at: https://app.socialidnow.com/marketing/apis.
+
* API_SECRET: The API_SECRET can be found at: https://app.socialidnow.com/marketing/apis.
+
  
== Add the SDK to your app ==
+
  include ':socialidsdk'
  
Add the following import statements to your Activity:
+
App specific ''app/build.gradle'' file:
  
   import com.coffeebeantech.socialidsdk.SocialId;
+
   dependencies {
   import com.coffeebeantech.socialidsdk.notification.NotificationParameters;
+
    implementation project(':socialidsdk')
 +
   }
  
Call SocialId.config from the onCreate method of your Application class to set your application SocialID configuration:
+
== Android Manifest ==
  
  SocialId.config(this, "SENDER_ID", "API_KEY", "API_SECRET", "LOGIN_APP_API_KEY", "LOGIN_APP_API_SECRET");
+
Add the following definitions to AndroidManifest.xml immediately before opening the ''<application>'' tag:
 
+
Add the following variables to res/values/strings.xml:
+
 
+
  <string name="app_id"></string> <!-- Facebook App ID -->
+
  <string name="client_id"></string> <!-- Google Client ID -->
+
  <string name="client_secret"></string> <!-- Google Client Secret -->
+
 
+
== Modify app manifest ==
+
 
+
Add the following definitions to AndroidManifest.xml immediately before opening the <application> tag:
+
  
 
   <uses-permission android:name="android.permission.INTERNET" />
 
   <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
 
 
   <uses-permission android:name="android.permission.USE_CREDENTIALS" />
 
   <uses-permission android:name="android.permission.USE_CREDENTIALS" />
 
+
 
 
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
 
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
 
   <uses-permission android:name="android.permission.WAKE_LOCK" />
 
   <uses-permission android:name="android.permission.WAKE_LOCK" />
Line 47: Line 35:
 
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 
   <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
 
   <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
  <permission
 
      android:name="com.YOUR_PACKAGE.C2D_MESSAGE"
 
      android:protectionLevel="signature" />   
 
 
   <uses-permission android:name="com.YOUR_PACKAGE.C2D_MESSAGE" />
 
   <uses-permission android:name="com.YOUR_PACKAGE.C2D_MESSAGE" />
 
   <nowiki><!-- END: use this if you need push notification support --></nowiki>
 
   <nowiki><!-- END: use this if you need push notification support --></nowiki>
  
Add the following definitions to AndroidManifest.xml inside the <application> tag:
+
Add the following definitions to AndroidManifest.xml inside the ''<application>'' tag:
 
+
  <meta-data
+
      android:name="com.google.android.gms.version"
+
      android:value="@integer/google_play_services_version" />
+
  <meta-data
+
      android:name="com.facebook.sdk.ApplicationId"
+
      android:value="@string/app_id" />
+
  <meta-data
+
      android:name="com.coffeebeantech.socialidsdk.client_id"
+
      android:value="@string/client_id" />
+
  <meta-data
+
      android:name="com.coffeebeantech.socialidsdk.client_secret"
+
      android:value="@string/client_secret" />
+
  <activity android:name="com.facebook.LoginActivity" >
+
  </activity>
+
  
 
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
 
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
Line 91: Line 61:
 
   <nowiki><!-- END: use this if you need push notification support --></nowiki>
 
   <nowiki><!-- END: use this if you need push notification support --></nowiki>
  
= New Project =
+
== Resources ==
  
== Download & unzip the sample project ==
+
Add the following variables to your resources file:
  
[http://www.example.com Download the project]
+
  <nowiki><!-- Social Id configuration --></nowiki>
 +
  <string name="login_app_id">LOGIN_APP_ID</string>;
 +
  <string name="login_app_client_secret">LOGIN_APP_CLIENT_SECRET</string>;
 +
 
 +
  <nowiki><!-- Google Project Number (if you need push notification support) --></nowiki>
 +
  <string name="sender_id">SENDER_ID</string>;
  
== Add the project to your workspace ==
+
== Usage ==
  
Unzip the file and move the socialid-sample-android into your workspace directory.
+
Add the following import statements to your Activity:
  
In Eclipse, go to File → Import…
+
  import com.coffeebeantech.socialidsdk.SocialId;
 +
  import com.coffeebeantech.socialidsdk.notification.NotificationParameters;
  
Click General → Existing Projects into Workspace
+
At your Activity onCreate method, call SocialId.configLoginProviders with the desired providers configuration and then call SocialId.config to set your Social-ID configuration using the resources set before:
 +
 
 +
  // pass the providers configuration that will be set
 +
  SocialId.configLoginProviders(facebookConfiguration, gplusConfiguration, linkedinConfiguration, twitterConfiguration, emailConfiguration);
 +
 
 +
  // with push notifications support
 +
  SocialId.config(this, "SENDER_ID", "LOGIN_APP_ID", "LOGIN_APP_CLIENT_SECRET");
 +
  // without push notifications support
 +
  SocialId.config(this, "LOGIN_APP_ID", "LOGIN_APP_CLIENT_SECRET");
  
Make sure the "Select root directory" radio button is selected, and browse to your workspace directory.
+
= Add Facebook Login to your app =
  
In the Projects box, check the box next to ParseStarterProject and click Finish. (Note: if your workspace isn't already set up for Android, you may need to specify the location of the Android SDK in the Android tab in preferences, in order to get the project to compile.)
+
Before starting to add the Facebook SDK, you must allow your Facebook App to receive requests from your Android project.
  
== Get your SocialID data ==
+
* At the Facebook for developers page, find your Facebook App at [https://developers.facebook.com/apps/ My Apps]
 +
* Go to Settings > Basic
 +
* At the end of page click on "Add a Platform" and then select "Android"
 +
* Add your project package name at "Google Play Package Name" and your default activity class name at "Class Name"
 +
* Export your Development Key Hash using the instructions for your operating system, add the exported key to "Key Hashes" and then "Save Changes" to proceed to next steps
 +
: MacOS
 +
  $ keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
 +
: Windows
 +
: You need the folowing:
 +
:* Key and Certificate Management Tool ('''keytool''') from the Java Development Kit
 +
:* [https://code.google.com/archive/p/openssl-for-windows/downloads openssl-for-windows] openssl library for Windows from the Google Code Archive
 +
  $ keytool -exportcert -alias androiddebugkey -keystore "C:\Users\USERNAME\.android\debug.keystore" | "PATH_TO_OPENSSL_LIBRARY\bin\openssl" sha1 -binary | "PATH_TO_OPENSSL_LIBRARY\bin\openssl" base64
  
You'll need 5 variables to configure the SDK:
+
Add the Facebook maven repository to your ''app/build.gradle'' before the ''dependencies'' area and add the latest Facebook SDK dependency to your list of dependencies:
  
* SENDER_ID: Set up a project on Google Developers Console - https://cloud.google.com/console/project. Get your project number. This will be used as the SENDER_ID in the SDK.
+
  repositories {
* LOGIN_APP_API_KEY: Set up an SocialId LoginApp at: https://app.socialidnow.com/marketing/login/apps. Your key is the id of the app. This will be used as the LOGIN_APP_API_KEY in the SDK.
+
    mavenCentral()
* LOGIN_APP_API_SECRET: The secret can be found at the Call the API menu - https://app.socialidnow.com/marketing/login/apps/APP_ID/apis. This will be used as the LOGIN_APP_API_SECRET in the SDK.
+
  }
* API_KEY: The API_KEY can be found at: https://app.socialidnow.com/marketing/apis.
+
 
* API_SECRET: The API_SECRET can be found at: https://app.socialidnow.com/marketing/apis.
+
  dependencies {
 +
    implementation 'com.facebook.android:facebook-android-sdk:4.40.0'
 +
  }
  
== Add the SDK to your app ==
+
== Android Manifest ==
  
Add the following import statements to your Activity:
+
Add the Facebook ApplicationId that will be used in your AndroidManifest.xml inside the <application> tag as following:
  
   import com.coffeebeantech.socialidsdk.SocialId;
+
   <meta-data
   import com.coffeebeantech.socialidsdk.notification.NotificationParameters;
+
    android:name="com.facebook.sdk.ApplicationId"
 +
    android:value="@string/facebook_app_id" />
 +
    
 +
  <nowiki><!-- If you want to make changes to the Facebook Login Activity you can do changes using the tag below --></nowiki>
 +
  <activity android:name="com.facebook.FacebookActivity"
 +
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
 +
    android:label="@string/app_name" />
 +
  </activity>
  
Call SocialId.config from the onCreate method of your Application class to set your application SocialID configuration:
+
== Resources ==
  
  SocialId.config(this, "SENDER_ID", "API_KEY", "API_SECRET", "LOGIN_APP_API_KEY", "LOGIN_APP_API_SECRET");
+
Add the following variables to your resources file:
  
Add the following variables to res/values/strings.xml:
+
  <!-- Facebook App ID -->
 +
  <string name="facebook_app_id">FACEBOOK_APP_ID</string>
 +
 
 +
  <string-array name="facebook_permissions">
 +
      <item>public_profile</item>
 +
      <item>user_birthday</item>
 +
      <item>email</item>
 +
      <item>user_location</item>
 +
  </string-array>
  
  <string name="app_id"></string> <!-- Facebook App ID -->
+
== Usage ==
  <string name="client_id"></string> <!-- Google Client ID -->
+
  <string name="client_secret"></string> <!-- Google Client Secret -->
+
  
== Modify app manifest ==
+
Initializes a new Facebook configuration and set the permissions:
  
Add the following definitions to AndroidManifest.xml immediately before opening the <application> tag:
+
  // Facebook configuration
 +
  FacebookConfiguration facebookConfiguration = new FacebookConfiguration()
 +
      .setPermissions("FACEBOOK_PERMISSIONS");
  
  <uses-permission android:name="android.permission.INTERNET" />
+
= Add Twitter Login to your app =
  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+
  <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+
  
  <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
+
Add the '''twittersdk://''' to your [https://developer.twitter.com/en/apps Twitter App] Callback URLs to allow an Android project to use it.
  <uses-permission android:name="android.permission.WAKE_LOCK" />
+
  <uses-permission android:name="android.permission.VIBRATE" />
+
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+
  <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
+
  <permission
+
      android:name="com.YOUR_PACKAGE.C2D_MESSAGE"
+
      android:protectionLevel="signature" />   
+
  <uses-permission android:name="com.YOUR_PACKAGE.C2D_MESSAGE" />
+
  <nowiki><!-- END: use this if you need push notification support --></nowiki>
+
  
Add the following definitions to AndroidManifest.xml inside the <application> tag:
+
Add the Twitter JCenter repository to your app/build.gradle before the dependencies area and add the Twitter SDK dependency to your list of dependencies:
  
   <meta-data
+
   repositories {
      android:name="com.google.android.gms.version"
+
    jcenter()
       android:value="@integer/google_play_services_version" />
+
  }
   <meta-data
+
 
      android:name="com.facebook.sdk.ApplicationId"
+
  dependencies {
      android:value="@string/app_id" />
+
    implementation('com.twitter.sdk.android:twitter:3.1.1') {
   <meta-data
+
       transitive = true;
      android:name="com.coffeebeantech.socialidsdk.client_id"
+
    }
      android:value="@string/client_id" />
+
   }
   <meta-data
+
 
      android:name="com.coffeebeantech.socialidsdk.client_secret"
+
== Resources ==
      android:value="@string/client_secret" />
+
 
   <activity android:name="com.facebook.LoginActivity" >
+
   <!-- Twitter Credentials -->
  </activity>
+
   <string name="twitter_key">TWITTER_KEY</string>
 +
   <string name="twitter_secret">TWITTER_SECRET</string>
  
   <nowiki><!-- BEGIN: use this if you need push notification support --></nowiki>
+
== Usage ==
   <receiver
+
 
       android:name="com.coffeebeantech.socialidsdk.notification.NotificationReceiver"
+
Initializes a new Twitter configuration and set the credentials:
       android:permission="com.google.android.c2dm.permission.SEND" >
+
 
      <intent-filter>
+
   // Twitter configuration
          <action android:name="com.google.android.c2dm.intent.RECEIVE" />
+
   TwitterConfiguration twitterConfiguration = new TwitterConfiguration()
          <category android:name="com.YOUR_PACKAGE" />
+
       .setTwitterKey("TWITTER_KEY")
      </intent-filter>
+
       .setTwitterSecret("TWITTER_SECRET");
   </receiver>
+
 
  <receiver
+
 
      android:name="com.coffeebeantech.socialidsdk.registration.ConnectivityMonitor"
+
= Add Google Login to your app =
      android:enabled="false" >
+
 
      <intent-filter>
+
To add the Google Login to your Android project you must:
          <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
+
 
          <category android:name="com.YOUR_PACKAGE" />
+
* Have an Android and a Web Application "OAuth client ID" [https://console.developers.google.com/apis/credentials Credentials]
      </intent-filter>
+
** The Android Credential must be set with the SHA1 signing-certificate fingerprint and the Package Name to the Login with Google work.  
   </receiver>
+
 
   <service android:name="com.coffeebeantech.socialidsdk.notification.NotificationService" />
+
Example to export the SHA1 from the debug key:
   <service android:name="com.coffeebeantech.socialidsdk.registration.RegistrationService" />
+
  $ keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v
   <nowiki><!-- END: use this if you need push notification support --></nowiki>
+
 
 +
 
 +
Add the latest Google GCM and Auth SDK dependency to your list of dependencies:
 +
 
 +
  dependencies {
 +
    implementation 'com.google.android.gms:play-services-gcm:16.0.0'
 +
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
 +
   }
 +
 
 +
== Resources ==
 +
 
 +
Add the Client ID from the created Web Application credential  to your resources file:
 +
  <nowiki><!-- Google Client Server ID --></nowiki>
 +
  <string name="google_client_server_id">"WEB_APPLICATION_CLIENT_ID"</string>;
 +
 
 +
== Usage ==
 +
 
 +
Initializes a new Gplus configuration and set the client server id with the Web Application client ID:
 +
   // Google+ configuration
 +
   GplusConfiguration gplusConfiguration = new GplusConfiguration()
 +
      .setClientServerId("WEB_APPLICATION_CLIENT_ID"));
 +
 
 +
= Add Linkedin Login to your app =
 +
 
 +
Add the following content to the ''assets/oauth_consumer.properties'' file. Custom Permissions must be a single string split by a comma (ex: r_liteprofile,r_emailaddress). Ensure the ''assets'' folder is at the same level as the ''res'' folder.
 +
   #linkedin
 +
  api.linkedin.com.consumer_key = LINKEDIN_CLIENT_ID
 +
  api.linkedin.com.consumer_secret = LINKEDIN_CLIENT_SECRET
 +
  api.linkedin.com.custom_permissions = LINKEDIN_PERMISSIONS
 +
 
 +
== Resources ==
 +
 
 +
Add the Linkedin Callback URI to your resources file:
 +
 
 +
   <nowiki><!-- Linkedin Callback URI --></nowiki>
 +
  <string name="linkedin_callback_uri">LINKEDIN_CALLBACK_URI</string>
 +
 
 +
== Usage ==
 +
 
 +
Initializes a new Linkedin configuration and set the callback uri:
 +
 
 +
  // LinkedIn configuration
 +
  LinkedinConfiguration linkedinConfiguration = new LinkedinConfiguration()
 +
      .setCallbackUri("LINKEDIN_CALLBACK_URI");

Latest revision as of 17:25, 20 August 2019

Contents

Configure CoffeeBean SDK in your app

You'll need 3 variables to configure the SDK:

Download the SDK

Download the SDK

Import the AAR file into your existing AndroidStudio as a new module and update your project and app .gradle files to include the new module.

Project settings.gradle file:

 include ':socialidsdk'

App specific app/build.gradle file:

 dependencies {
   implementation project(':socialidsdk')
 }

Android Manifest

Add the following definitions to AndroidManifest.xml immediately before opening the <application> tag:

 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.USE_CREDENTIALS" />
 
 <!-- BEGIN: use this if you need push notification support -->
 <uses-permission android:name="android.permission.WAKE_LOCK" />
 <uses-permission android:name="android.permission.VIBRATE" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
 <uses-permission android:name="com.YOUR_PACKAGE.C2D_MESSAGE" />
 <!-- END: use this if you need push notification support -->

Add the following definitions to AndroidManifest.xml inside the <application> tag:

 <!-- BEGIN: use this if you need push notification support -->
 <receiver
     android:name="com.coffeebeantech.socialidsdk.notification.NotificationReceiver"
     android:permission="com.google.android.c2dm.permission.SEND" >
     <intent-filter>
         <action android:name="com.google.android.c2dm.intent.RECEIVE" />
         <category android:name="com.YOUR_PACKAGE" />
     </intent-filter>
 </receiver>
 <receiver
     android:name="com.coffeebeantech.socialidsdk.registration.ConnectivityMonitor"
     android:enabled="false" >
     <intent-filter>
         <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
         <category android:name="com.YOUR_PACKAGE" />
     </intent-filter>
 </receiver>
 <service android:name="com.coffeebeantech.socialidsdk.notification.NotificationService" />
 <service android:name="com.coffeebeantech.socialidsdk.registration.RegistrationService" />
 <!-- END: use this if you need push notification support -->

Resources

Add the following variables to your resources file:

 <!-- Social Id configuration -->
 <string name="login_app_id">LOGIN_APP_ID</string>;
 <string name="login_app_client_secret">LOGIN_APP_CLIENT_SECRET</string>;
 
 <!-- Google Project Number (if you need push notification support) -->
 <string name="sender_id">SENDER_ID</string>;

Usage

Add the following import statements to your Activity:

 import com.coffeebeantech.socialidsdk.SocialId;
 import com.coffeebeantech.socialidsdk.notification.NotificationParameters;

At your Activity onCreate method, call SocialId.configLoginProviders with the desired providers configuration and then call SocialId.config to set your Social-ID configuration using the resources set before:

 // pass the providers configuration that will be set
 SocialId.configLoginProviders(facebookConfiguration, gplusConfiguration, linkedinConfiguration, twitterConfiguration, emailConfiguration);
 
 // with push notifications support
 SocialId.config(this, "SENDER_ID", "LOGIN_APP_ID", "LOGIN_APP_CLIENT_SECRET");
 // without push notifications support
 SocialId.config(this, "LOGIN_APP_ID", "LOGIN_APP_CLIENT_SECRET");

Add Facebook Login to your app

Before starting to add the Facebook SDK, you must allow your Facebook App to receive requests from your Android project.

  • At the Facebook for developers page, find your Facebook App at My Apps
  • Go to Settings > Basic
  • At the end of page click on "Add a Platform" and then select "Android"
  • Add your project package name at "Google Play Package Name" and your default activity class name at "Class Name"
  • Export your Development Key Hash using the instructions for your operating system, add the exported key to "Key Hashes" and then "Save Changes" to proceed to next steps
MacOS
 $ keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 
Windows
You need the folowing:
  • Key and Certificate Management Tool (keytool) from the Java Development Kit
  • openssl-for-windows openssl library for Windows from the Google Code Archive
 $ keytool -exportcert -alias androiddebugkey -keystore "C:\Users\USERNAME\.android\debug.keystore" | "PATH_TO_OPENSSL_LIBRARY\bin\openssl" sha1 -binary | "PATH_TO_OPENSSL_LIBRARY\bin\openssl" base64

Add the Facebook maven repository to your app/build.gradle before the dependencies area and add the latest Facebook SDK dependency to your list of dependencies:

 repositories {
   mavenCentral() 
 }
 
 dependencies { 
   implementation 'com.facebook.android:facebook-android-sdk:4.40.0'
 }

Android Manifest

Add the Facebook ApplicationId that will be used in your AndroidManifest.xml inside the <application> tag as following:

 <meta-data
    android:name="com.facebook.sdk.ApplicationId"
    android:value="@string/facebook_app_id" />
 
 <!-- If you want to make changes to the Facebook Login Activity you can do changes using the tag below -->
 <activity android:name="com.facebook.FacebookActivity"
    android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name" />
 </activity>

Resources

Add the following variables to your resources file:

 <string name="facebook_app_id">FACEBOOK_APP_ID</string>
 
 <string-array name="facebook_permissions">
     <item>public_profile</item>
     <item>user_birthday</item>
     <item>email</item>
     <item>user_location</item>
 </string-array>

Usage

Initializes a new Facebook configuration and set the permissions:

 // Facebook configuration
 FacebookConfiguration facebookConfiguration = new FacebookConfiguration()
     .setPermissions("FACEBOOK_PERMISSIONS");

Add Twitter Login to your app

Add the twittersdk:// to your Twitter App Callback URLs to allow an Android project to use it.

Add the Twitter JCenter repository to your app/build.gradle before the dependencies area and add the Twitter SDK dependency to your list of dependencies:

 repositories {
   jcenter()
 }
 
 dependencies {
   implementation('com.twitter.sdk.android:twitter:3.1.1') {
     transitive = true;
   }
 }

Resources

 <string name="twitter_key">TWITTER_KEY</string>
 <string name="twitter_secret">TWITTER_SECRET</string>

Usage

Initializes a new Twitter configuration and set the credentials:

 // Twitter configuration
 TwitterConfiguration twitterConfiguration = new TwitterConfiguration()
     .setTwitterKey("TWITTER_KEY")
     .setTwitterSecret("TWITTER_SECRET");


Add Google Login to your app

To add the Google Login to your Android project you must:

  • Have an Android and a Web Application "OAuth client ID" Credentials
    • The Android Credential must be set with the SHA1 signing-certificate fingerprint and the Package Name to the Login with Google work.

Example to export the SHA1 from the debug key:

 $ keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v


Add the latest Google GCM and Auth SDK dependency to your list of dependencies:

 dependencies {
   implementation 'com.google.android.gms:play-services-gcm:16.0.0'
   implementation 'com.google.android.gms:play-services-auth:16.0.1'
 }

Resources

Add the Client ID from the created Web Application credential to your resources file:

 <!-- Google Client Server ID -->
 <string name="google_client_server_id">"WEB_APPLICATION_CLIENT_ID"</string>; 

Usage

Initializes a new Gplus configuration and set the client server id with the Web Application client ID:

 // Google+ configuration
 GplusConfiguration gplusConfiguration = new GplusConfiguration()
     .setClientServerId("WEB_APPLICATION_CLIENT_ID"));

Add Linkedin Login to your app

Add the following content to the assets/oauth_consumer.properties file. Custom Permissions must be a single string split by a comma (ex: r_liteprofile,r_emailaddress). Ensure the assets folder is at the same level as the res folder.

 #linkedin
 api.linkedin.com.consumer_key = LINKEDIN_CLIENT_ID
 api.linkedin.com.consumer_secret = LINKEDIN_CLIENT_SECRET
 api.linkedin.com.custom_permissions = LINKEDIN_PERMISSIONS 

Resources

Add the Linkedin Callback URI to your resources file:

 <!-- Linkedin Callback URI -->
 <string name="linkedin_callback_uri">LINKEDIN_CALLBACK_URI</string>

Usage

Initializes a new Linkedin configuration and set the callback uri:

 // LinkedIn configuration
 LinkedinConfiguration linkedinConfiguration = new LinkedinConfiguration()
     .setCallbackUri("LINKEDIN_CALLBACK_URI");
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox