MessengerUtils
Non è disponibile una versione più recente di questa classe. Controlla la versione più recente.

Utilities for Messenger Content Platform.

Applications should specify the app id in their manifest or call MessengerUtils.setAppId(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 Sened button to send the content to Messenger, ten call MessengerUtils.finishShareToMessenger to return the data back to Messenger.

Estende:Object
Pacchetto:messenger
Costruttori
MessengerUtils()
public MessengerUtils()
Metodi di classe
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)
ParametroDescrizione
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)
ParametroDescrizione
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)
ParametroDescrizione
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)
ParametroDescrizione
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)
ParametroDescrizione
contextAn android context.
Costanti
PACKAGE_NAME
public static final String PACKAGE_NAME
APPLICATION_ID_PROPERTY
public static final String APPLICATION_ID_PROPERTY
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