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.

延伸:Object
套件:messenger
建構函式
MessengerUtils()
public MessengerUtils()
類別方式
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)
參數說明
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)
參數說明
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)
參數說明
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)
參數說明
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)
參數說明
contextAn android context.
常數
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