2015-06-20 74 views
0

我使用ShareOpenGraphContent在我的Android應用程序中通過Facebook OpenGraph共享圖像,它僅在安裝Facebook時起作用。如何在未安裝Facebook的情況下在Android上使用ShareOpenGraphContent

SharePhoto photo = new SharePhoto.Builder() 
      .setBitmap(bitmap) 
      .setCaption("https://play.google.com/store/apps/details?id=" + 
        G.app.getPackageName()) 
      .build(); 

    // Create an object 
    ShareOpenGraphObject object = new ShareOpenGraphObject.Builder() 
      .putString("og:type", "my app:type") 
      .putString("og:title", "my app title") 
      .putString("og:url", "https://market.android.com/details?id=" + G.app.getPackageName()) 
      .putPhoto("og:image", photo) 
      .build(); 

    // Create an action 
    ShareOpenGraphAction action = new ShareOpenGraphAction.Builder() 
      .setActionType("my app:object") 
      .putObject("my object", object) 
      .build(); 

    // Create the content 
    ShareOpenGraphContent content = new ShareOpenGraphContent.Builder() 
      .setPreviewPropertyName("type") 
      .setAction(action) 
      .build(); 

    final ShareButton shareButton = (ShareButton) findViewById(R.id.facebookShare); 
    shareButton.setShareContent(content); 
    shareButton.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      // do some thing 
      bitmap.recycle(); 
     } 
    }); 

G.applife cycle API。

我知道我需要發佈操作權限和facebook批准,因爲此開放圖表在未安裝Facebook應用程序的情況下工作。但我該怎麼做?我想向用戶展示他們在Facebook應用安裝時看到的對話框。

回答

0

如果未安裝FB應用程序,正常的回退是一個網頁對話框,但網頁對話框不支持位圖(只有圖片的url),這可能是爲什麼它不適合你。

您需要將圖片切換爲網頁網址,或者使用ShareApi類以及publish_actions權限(但在這種情況下,您的用戶將不會有對話框)。

+0

你描述的很好,現在需要找到解決方案。未安裝Facebook應用程序時如何顯示對話框。 –

+0

P.S網頁對話框中沒有任何正常現象;) –

相關問題