-
public class MessengerUtilsUtilities for Messenger Content Platform.
Applications should specify the app id in their manifest or call } in their application startup path. For specifying in the manifest, add a meta tag in your <application> tag.
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="YOUR_APP_ID"/>When sharing to Messenger, apps should call the shareToMessenger method. For example,
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:ShareToMessengerParams params = ShareToMessengerParams.newBuilder(uri, "image/*") .setMetaData(metaData) .build(); MessengerUtils.shareToMessenger(this, REQUEST_CODE_SHARE_TO_MESSENGER, params);
When handling the intent, then call getMessengerThreadParamsForIntent to receive the parameters for messenger. When the user has clicked the Send button to send the content to Messenger, then call finishShareToMessenger to return the data back to Messenger.<intent-filter> <action android:name="android.intent.action.PICK" /> <category android:name="android.intent.category.DEFAULT"/> <category android:name="com.facebook.orca.category.PLATFORM_THREAD_20150311"/> </intent-filter>
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringPACKAGE_NAMEpublic final static StringEXTRA_PROTOCOL_VERSIONpublic final static StringEXTRA_APP_IDpublic final static StringEXTRA_REPLY_TOKEN_KEYpublic final static StringEXTRA_THREAD_TOKEN_KEYpublic final static StringEXTRA_METADATApublic final static StringEXTRA_EXTERNAL_URIpublic final static StringEXTRA_PARTICIPANTSpublic final static StringEXTRA_IS_REPLYpublic final static StringEXTRA_IS_COMPOSEpublic final static intPROTOCOL_VERSION_20150314public final static StringORCA_THREAD_CATEGORY_20150314
-
Method Summary
Modifier and Type Method Description static voidshareToMessenger(Activity activity, int requestCode, ShareToMessengerParams shareToMessengerParams)Starts an intent to share a piece of media on Messenger using the messenger content platform. static MessengerThreadParamsgetMessengerThreadParamsForIntent(Intent intent)When handling an {@code Intent}from Messenger, call this to parse the parameters of theintent.static voidfinishShareToMessenger(Activity activity, ShareToMessengerParams shareToMessengerParams)Finishes the activity and returns the media item the user picked to Messenger. static booleanhasMessengerInstalled(Context context)Checks whether any version of messenger is installed. static voidopenMessengerInPlayStore(Context context)Opens the play store to install Messenger. -
-
Method Detail
-
shareToMessenger
static void shareToMessenger(Activity activity, int requestCode, ShareToMessengerParams shareToMessengerParams)
Starts an intent to share a piece of media on Messenger using the messenger content platform.
- Parameters:
activity- the activity sharing the contentrequestCode- a unique request code for startActivityForResultshareToMessengerParams- parameters for what to share
-
getMessengerThreadParamsForIntent
static MessengerThreadParams getMessengerThreadParamsForIntent(Intent intent)
When handling an
{@code Intent}from Messenger, call this to parse the parameters of theintent.- Parameters:
intent- the intent of the activity
-
finishShareToMessenger
static void finishShareToMessenger(Activity activity, ShareToMessengerParams shareToMessengerParams)
Finishes the activity and returns the media item the user picked to Messenger.
- Parameters:
activity- the activity that received the original intent from MessengershareToMessengerParams- parameters for what to share
-
hasMessengerInstalled
static boolean hasMessengerInstalled(Context context)
Checks whether any version of messenger is installed.
- Parameters:
context- an android context
-
openMessengerInPlayStore
static void openMessengerInPlayStore(Context context)
Opens the play store to install Messenger.
- Parameters:
context- an android context.
-
-
-
-