Android Pin It SDK

Help people share from your Android app.

Updated Decemeber 18th, 2013

Overview

With the launch of Pinterest version 1.3 for Android, we’ll be supporting the Pin It Button SDK for your Android app. This SDK lets your users create Pinterest content inside your app with just a few lines of code. We support two types of Pin sources: image URL and image URI. Image URL lets you specify the direct path to an image on the web, while image URI lets you specify a path on the device.

This SDK requires the Pinterest app to be installed. We’ve provided helper methods to determine if Pin It Button SDK is supported and Pinterest 1.3 or higher is installed. This should allow you to remove Pin It in cases where it is not.

Using the SDK

Register for a Client ID

Download the documentation and SDK

First place the pinit-sdk.jar folder into YOUR_PROJECT/libs and integrate into your IDE or build system.

Then we need to do a one time setup.

    PinItButton.setPartnerId("YOUR_PARTNER_ID"); // required
    PinItButton.setDebugMode(true); // optional

To use the PinIt button in an XML layout first add it like so.

    <com.pinterest.external.PinItButton
        android:id="@+id/pin_it"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

Next, find the button and set some properties

    PinItButton pinIt = (PinItButton) findViewById(R.id.pin_it);
    pinIt.setImageUrl("http://placekitten.com/400/300");
    pinIt.setUrl("http://placekitten.com"); // optional
    pinIt.setDescription("A place kitten!"); // optional

Alternatively, we can instantiate and add the button entirely in Java.

    PinItButton pinIt = new PinItButton(this);
    pinIt.setImageUrl("http://placekitten.com/400/300");
    pinIt.setUrl("http://placekitten.com");
    pinIt.setDescription("A place kitten!");
    view.addView(pinIt);

Deep Linking

Pinterest for Android supports deep linking of Pins, Pinners and boards in two ways. First, when using the standard Android Browser or other native apps, any normal Pinterest link is capable of being opened in our app. The recommended option for developers is to use a URI scheme as seen below.

Pin

pinterest://www.pinterest.com/pin/275423333434060623/

Board

pinterest://www.pinterest.com/carlrice/cats/

User

pinterest://www.pinterest.com/carlrice/

What files are included:

  • • The library: pinit-sdk-1.0.jar
  • • The java doc: pinit-sdk-1.0-javadoc.jar
  • • The zipped api doc: apidocs.zip.
  • • The Pinterest main apk that works with the pinit feature: pinterest-release.apk
  • • The demo project using the SDK's pinit feature: PinItDemo.zip

What's in the PinItDemo:

  • The PinItDemo gives 3 examples of how to use the Pin It button:
  • 1. "Simple PinIt Demo": shows how to add a single image from network, with listener.
  • 2. "PinIt from Gallery": shows how to add a single image from your Gallery app.
  • 3. "PinIt in ListView": shows a listview containing images from network, and you can add each image in the list.

How to use the PinItDemo in Eclipse:

  • 1. Copy the PinItDemo.zip to your working directory and unzip it.
  • 2. In Eclipse, choose File -> Import… -> Existing projects into workspace. Select the PinItDemo folder.
  • 3. You should see be a PinItDemo project. Click Finish.
  • 4. Put your Client ID in the field CLIENT_ID in file DemoMainActivity.java
  • 5. Right click the PinItDemo project and run as-> Android Application.
  • 6. Click the demo you want to play, and have fun adding Pins! (Note: If you’re not logged into the Pinterest app yet, it will prompt you to log in first.)