Quickstart Guide | Documentation
This guide will help you get up and running quickly with the Android SDK. Check out the full documentation for all the details.Step 1: Download
Step 2: Check out the Demo
The SDK includes a basic demo application, AddThisDemo, which illustrates the various common ways the library can be used to add sharing to an application. Take a look, this will give you the basic idea of how the library works. When you've got the concept, continue on to add sharing to your own application.Follow the steps given below for installing the Demo project into Eclipse :
1. You need to setup the AddThisSDK first to install the demo app. Open Eclipse and create a new Android project. At the 'New Android Project' window, choose 'Create project from existing source' and specify the AddThisSDK from addthis-android-sdk-<version>/AddThisSDK/. Give AddThisSDK as the 'Project Name' and click on 'Finish'.
2. Now create another Android project and specify the AddThisDemo (addthis-android-sdk-<version>/AddThisDemo/) at 'Create project from exiting source'. Give AddThisDemo as the 'Project Name' and click on 'Finish'.
3. We need to refer the AddThisSDK and other libraries used with AddThisDemo. Open the property window of the AddThisDemo project (File - Properties). Select 'Java Build Path' and take 'External JARs', then specify the two jars present in addthis-android-sdk-<version>/third-party/. Now go to 'Add JARs' and specify the addthis<version>.jar present in addthis-android-sdk-<version>/AddThisSDK/lib/.
4. From the 'Property window' of AddThisDemo project go to 'Android' and add AddThisSDK as library project if its not already added.
5. Build and Run AddThisDemo.
Step 3: Install AddThis into your project
The AddThis Android SDK is shipped as a library project, so you can add this to any android project as a library. First, open Eclipse and create a new Android project. At the 'New Android Project' window, choose 'Create project from existing source' and specify the AddThisSDK from addthis-android-sdk-<version>/AddThisSDK/. Give AddThisSDK as the 'Project Name' and click on 'Finish'.Now in your project properties select "Android" and add AddThisSDK under the section “Library”. Then go to 'Java Build Path' of your project and take 'Add JARs', add addthis<version>.jar from addthis-android-sdk-<version>/AddThisSDK>lib.
Android SDK requires some libraries for its proper functioning. Again go to the ‘Java Build Path’ of your project properties and take “External Jars”, and add the jar files available at addthis-android-sdk-<version>/third-party/.
The SDK needs a prepopulated database 'AddThisDB' with the service list which you can get it from addthis-android-sdk-<version>/AddThisDemo/assets/. Copy this database file to the assets folder of your project.
Step 4: Setup the Manifest file
Add the following activities to your manifest file inside the application tag:<activity android:name="com.addthis.ui.activities.ATAllServiceActivity" />
<activity android:name="com.addthis.ui.activities.ATFavoriteServiceActivity" />
<activity android:name="com.addthis.ui.activities.ATShareActivity" />
<activity android:name="com.addthis.ui.activities.ATActivityGroup" android:configChanges="orientation" />
Also mention the following permissions:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Step 5: Optionally Configure Facebook and Twitter API Keys
If you want to use Facebook and Twitter native sharing integrations, configure the library to do so, and specify the API keys it should use with Config object. If you just want to use the plain browser-based sharing to these services, you don't need to take this step.
Config.configObject().setTwitterConsumerKey("<your-consumer-key>");
Config.configObject().setTwitterConsumerSecret("<your-consumer-secret>");
Config.configObject().setTwitterCallbackUrl("<any-url-need-not-be-existing-one>");
Config.configObject().setFacebookAppId("<your-fb-appid>");
For more information on this process, see the full documentation.
Step 5: Add a Sharing Button or Menu
There are quite a few different ways to add basic sharing features into your application, all outlined in the full documentation. To get started, the simplest method is just to add an AddThis button to your app, or to render the AddThis sharing menu from your own UI callback.Add an AddThis Button To Your App
You can add the AddThis button either through the xml or directly through code to your view.To add a button through XML:
<com.addthis.ui.views.ATButton android:id="@+id/addthisButton" android:layout_height="wrap_content" android:layout_width="wrap_content" />
To add a button to a view with code:
ATButton button = new ATButton(this,"http://www.example.com","Check this out","Lorem ipsum dolor");
yourview.addView(button);
After adding the button you should grab it and assign the share items:
ATButton btn = (ATButton)findViewById(R.id.addthisButton);
ATShareItem item = new ATShareItem("http://www.example.com","Check this out","Lorem ipsum dolor");
btn.setItem(item);
Render the AddThis Sharing Menu from Your Own UI Callback
To display a sharing menu, use the following code:AddThis.presentAddThisMenu(this, "http;//www.addthis.com", "title", "description");
Step 6: Set Up Analytics
AddThis provides real time analytics on how your content is being shared on the social web. The SDK measures your content's impact across social networks and information about your audience. For more details please check our analytics features page.To set up analytics for your app, just follow these steps:
- If you haven't already, register a new account.
- At the end of the registration process, when asked about getting analytics for a 3rd party app, select "Get One Now"
- You'll receive a Publisher Profile ID that you will use to configure your app; make a note of it
- Click "Continue", then go to "Settings" and select "Profiles"
- Select "My Profile", or the profile to which you'd like to associate your app, and scroll down to "Applications"
- Select "Register a New Application", give your app a name to identify it in analytics reports, and click "Register"
Config.java
.Config.configObject().setAddThisAppId("<your-app-id>");
Config.configObject().setAddThisPubId("<your-publisher-profile-id>");