Android Share - Facebook SDK - ShareActionProvider

此生再无相见时 提交于 2020-01-13 10:04:52

问题


I am trying to implement sharing a simple string inside my application. Obviously everything other than Facebook works. As far as I know, now I have to use their Facebook SDK to post statuses on a wall.

However, if I do implement it using their SDK, is there a way to have it incorporated into the chooser (default or ShareActionProvider) and somehow override it and insert the Facebook SDK's implementation?

Or do I have to create a dedicated button?

//EDIT

package com.example.shareactionproviderdemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Test message");
        startActivity(Intent.createChooser(sharingIntent, "Share using"));
    }

}


回答1:


The answer is you cannot share a string to the user's own wall by using intents. You need the SDK in order to do that. The reason why is because Facebook does not allow the prefilling of the user's status update as seen in Platform Policy IV.2.

However, if you use the SDK, we have provided a feed dialog that prompts the user to share a status and it allows parts of the status update to be prefilled by the developer. It is not incorporated into the Android's native chooser, however.

The external bug report that tracked this issue is here.



来源:https://stackoverflow.com/questions/13371663/android-share-facebook-sdk-shareactionprovider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!