Android Content Sharing

To take advantage of this new feature in Flurry analytics, you’ll need to download the latest Flurry SDK for Android. The feature is enabled starting wiht the iOS SDK version 6.0. Once you download the new SDK, make sure that you replace any existing Flurry library folders from your project’s file folder with the latest files before proceeding.

Follow the steps described in this guide.

The sample app that implements Tumblr in-app sharing, is avalable from the gitHub. The accompanying blog post is available.

Log in to the Flurry Dashboard and Enable Content Sharing

To post content to Tumblr, you’ll need to enable your app for Content Sharing.

  1. Navigate to YourApplication > Manage
  2. Select App Info.
  3. In the Application Info panel, click Enable content sharing.

content sharing with tumblr

Add FlurryShareActivity to AndroidManifest.xml

You’ll need to include the FlurryShareActivity in your AndroidManifest.xml file. This is mandatory if you wish to display a Tumblr Post.

You also need to include the theme described below to achieve the desired UI experience with transparent backgrounds.

<activity android:name="com.flurry.android.FlurryShareActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|ui
Mode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent.NoTitleBar"/>

Set the Consumer API Key and Secret

Use the following method to set the consumer API key and secret:

import com.flurry.android.tumblr.TumblrShare;
String apiKey = “CONSUMER_API_KEY”;

String secret = “CONSUMER_API_SECRET”;
TumblrShare.setOAuthConfig(apiKey, secret);

Important

You’ll need to generate Tumblr oAuth keys at https://www.tumblr.com/oauth/apps. You’ll need these keys for users to be able to authenticate your app to post to Tumblr.

Display the Tumblr Button/ImageView in your Feed

If you want to use your own Tumblr button, you can do so. Otherwise, use the following method to get a default Tumblr button image:

Bitmap tumblrBtnBitmap = TumblrShare.getTumblrImage();

Create and Send a Post

Follow these steps for sending photo and text posts.

Photo Share Parameters

The following table describes the photo sharing parameters that you need to send when you’re sharing a photo post to Tumblr.

Photo Description
urlToPost The url to post. This can be an http(s) url or a valid file path. We recommend using a high-quality photo for better rendering and improved user experience.
setCaption Caption text for the image that needs to be shared.
setIOSDeepLink [optional - highly recommended] Your app’s iOS deep link to the photo content.
setAndroidDeepLink [optional - highly recommended] Your app’s Android deep link to the photo content.
setWebLink [optional - highly recommended] Your app’s Web link to the photo content.

To send an Photo Post, use this code snippet:

String url = "https://someexampleimage.com/123.jpg";
String caption = "Having a great time!";
PhotoPost post = new PhotoPost(url);
post.setCaption(caption);
post.setAndroidDeeplink("Your App’s Android Deep Link to content"); //optional
post.setIOSDeepLink("YourApp’siOSDeepLinktoContent"); //optional
post.setWebLink("Your App’s Web Link");
post.setPostListener(new PostListener() {
    @Override
    public void onPostSuccess(String postId) {
    } // optional

    @Override

    public void onPostFailure(int errorCode, String errorMessage) {

}
});

A Photo Post Example

This example illustrates a photo post without a caption. You can add a caption if you want.

content sharing with tumblr

Note the following:

  • The Url for the photo cannot be null.
  • The Url can only be a valid file or http(s) url.
  • The PhotoPost url is mandatory. Note that in order to provide a good user experience, it is strongly advised to provide deeplinks and a web link to the photo content.
  • If you’re posting a valid file to Tumblr, include the android.permission.READ_EXTERNAL_STORAGE permission in your manifest file.
  • Deeplinking enables you to click a button that shares the content. A Deeplink is the URL that will be called when a user clicks the shared content in the Tumblr app.

Text Share Parameters

The following table describes the text sharing parameters that you need to send when you’re sharing a text post to Tumblr.

Text Description
body The text content to post.
setTitle The title of the text post.
setIOSDeepLink [optional - highly recommended] Your app’s iOS deep link to the text content.
setAndroidDeepLink [optional - highly recommended] Your app’s Android deep link to the text content.
setWebLink [optional - highly recommended] Your app’s Web link to the text content.

To send a Text Post, use this code snippet:

String title = "Post title"; // Post title
String body = "Post body"; // Post body
TextPost post = new TextPost(body);
post.setTitle(title);
post.setAndroidDeeplink("Your App’s Android Deep Link to content"); // optional
post.setIOSDeepLink("YourApp’siOSDeepLinktoContent"); //optional
post.setWebLink("Your App’s Web Link");
post.setPostListener(new PostListener()  { // optional
        @Override
        public void onPostSuccess(Long postId) {
        }

        @Override
        public void onPostFailure(String errorMessage) {
        }
});
TumblrShare.post(context, post);

A Text Post Example

This example illustrates a text post with a title and body.

content sharing with tumblr

Note the following:

  • A Post body cannot be null or empty.
  • For a text post, only the body is mandatory. All other fields are optional. Note that in order to provide good user experience, it is strongly advised to provide deeplinks and web link. Listen to the PostListener events to handle the success and failure cases appropriately.

Listener methods

  • onPostSuccess. Fired when post is successfully created. It also returns the postId created by Tumblr.
  • onPostFailure. This listener method is fired when a post fails due to any reason. This listener is fired with a user-friendly errorMessage explaining the reason for the failure.