MessengerUtils

Utilities for Messenger Content Platform.

Applications should specify the app id in their manifest or call FacebookSdk.setApplicationId(String) } in their application startup path. For specifying in the manifest, add a meta tag in your <application> tag.

&lt;meta-data android:name="com.facebook.sdk.ApplicationId" android:value="YOUR_APP_ID"/&gt;

When sharing to Messenger, apps should call the MessengerUtils.shareToMessenger method. For example,

 ShareToMessengerParams params = ShareToMessengerParams.newBuilder(uri, "image/*")
     .setMetaData(metaData)
     .build();
 MessengerUtils.shareToMessenger(this, REQUEST_CODE_SHARE_TO_MESSENGER, params);

To handle receiving a composer shortcut or reply intent from Messenger, apps should put the following intent filter in their manifest for the activity that receives the intent:

       &lt;intent-filter&gt;
         &lt;action android:name="android.intent.action.PICK" /&gt;
         &lt;category android:name="android.intent.category.DEFAULT"/&gt;
         &lt;category android:name="com.facebook.orca.category.PLATFORM_THREAD_20150311"/&gt;
       &lt;/intent-filter&gt;

When handling the intent, then call MessengerUtils.getMessengerThreadParamsForIntent to receive the parameters for messenger. When the user has clicked the Send button to send the content to Messenger, then call MessengerUtils.finishShareToMessenger to return the data back to Messenger.

Erweiterungen:Object
Package:messenger
Konstruktoren
MessengerUtils()
public MessengerUtils()
Klassenmethoden
shareToMessenger(Activity, int, ShareToMessengerParams)

Starts an intent to share a piece of media on Messenger using the messenger content platform.

public static void shareToMessenger(Activity activity, int requestCode, ShareToMessengerParams shareToMessengerParams)
ParameterBeschreibung
activityThe activity sharing the content
requestCodeA unique request code for Activity.startActivityForResult
shareToMessengerParamsParameters for what to share
getMessengerThreadParamsForIntent(Intent)

When handling an Intent from Messenger, call this to parse the parameters of the intent.

public static MessengerThreadParams getMessengerThreadParamsForIntent(Intent intent)
ParameterBeschreibung
intentThe intent of the activity
Returns
A <a href='MessengerThreadParams'>MessengerThreadParams</a> or null if this intent wasn't recognized as a request from Messenger to share.
finishShareToMessenger(Activity, ShareToMessengerParams)

Finishes the activity and returns the media item the user picked to Messenger.

public static void finishShareToMessenger(Activity activity, ShareToMessengerParams shareToMessengerParams)
ParameterBeschreibung
activityThe activity that received the original intent from Messenger
shareToMessengerParamsParameters for what to share
hasMessengerInstalled(Context)

Checks whether any version of messenger is installed.

public static boolean hasMessengerInstalled(Context context)
ParameterBeschreibung
contextAn android context
Returns
Whether any version of messenger is installed
openMessengerInPlayStore(Context)

Opens the play store to install Messenger.

public static void openMessengerInPlayStore(Context context)
ParameterBeschreibung
contextAn android context.
Konstanten
PACKAGE_NAME
public static final String PACKAGE_NAME
EXTRA_PROTOCOL_VERSION
public static final String EXTRA_PROTOCOL_VERSION
EXTRA_APP_ID
public static final String EXTRA_APP_ID
EXTRA_REPLY_TOKEN_KEY
public static final String EXTRA_REPLY_TOKEN_KEY
EXTRA_THREAD_TOKEN_KEY
public static final String EXTRA_THREAD_TOKEN_KEY
EXTRA_METADATA
public static final String EXTRA_METADATA
EXTRA_EXTERNAL_URI
public static final String EXTRA_EXTERNAL_URI
EXTRA_PARTICIPANTS
public static final String EXTRA_PARTICIPANTS
EXTRA_IS_REPLY
public static final String EXTRA_IS_REPLY
EXTRA_IS_COMPOSE
public static final String EXTRA_IS_COMPOSE
PROTOCOL_VERSION_20150314
public static final int PROTOCOL_VERSION_20150314
ORCA_THREAD_CATEGORY_20150314
public static final String ORCA_THREAD_CATEGORY_20150314