2017-01-26 32 views
0

請我是新來的Android,我一直在開發一個應用程序的信使一週風格(研究和嘗試瞭解代碼...等),它包括髮送消息給我在Facebook上的朋友。因此消息被髮送,它包含一張圖片。我的問題是我怎麼能只發送消息如何發送只有來自android messenge應用程序的消息

這是迄今爲止我的,因爲該活動的部分代碼發送: `私人無效onMessengerButtonClicked(){

Uri uri = Uri.parse("android.resource://inboxapp.example.com.inboxapp/" + R.drawable.cover); 

    // Create the parameters for what we want to send to Messenger. 
    ShareToMessengerParams shareToMessengerParams = 
      ShareToMessengerParams.newBuilder(uri, "image/jpeg") 
        .setMetaData("{ \"image\" : \"tree\" }") 
        .build(); 

    if (mPicking) { 
     // If we were launched from Messenger, we call MessengerUtils.finishShareToMessenger to return 
     // the content to Messenger. 
     MessengerUtils.finishShareToMessenger(this, shareToMessengerParams); 
    } else { 
     // Otherwise, we were launched directly (for example, user clicked the launcher icon). We 
     // initiate the broadcast flow in Messenger. If Messenger is not installed or Messenger needs 
     // to be upgraded, this will direct the user to the play store. 
     MessengerUtils.shareToMessenger(
       this, 
       REQUEST_CODE_SHARE_TO_MESSENGER, 
       shareToMessengerParams); 
    } 
}` 

請我是卡在那個級別,我看到SDK 4.x不允許這個了,是否有沒有可能的解決方法?

謝謝

回答

0

您是否嘗試過把空或離開它空

圖像傳遞null值。

ShareToMessengerParams shareToMessengerParams = 
     ShareToMessengerParams.newBuilder(uri, "null") 
       .setMetaData("{ \"image\" : \"tree\" }") 
       .build(); 

傳遞圖像的空值。

ShareToMessengerParams shareToMessengerParams = 
     ShareToMessengerParams.newBuilder(uri, "") 
       .setMetaData("{ \"image\" : \"tree\" }") 
       .build(); 
+0

感謝您的回答,但我的應用程序崩潰時,我嘗試使value =「」或null,沒有提供任何錯誤。謝謝 –

相關問題