gpt4 book ai didi

安卓 Facebook Intent

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:52:45 28 4
gpt4 key购买 nike

我正在使用此代码在 Facebook 上发帖,但它不适用于官方 Facebook 应用程序,因为它试图以链接形式发送。有什么办法解决这个问题吗?

Intent s = new Intent(android.content.Intent.ACTION_SEND);

s.setType("text/plain");
s.putExtra(Intent.EXTRA_SUBJECT, "Quote");
s.putExtra(Intent.EXTRA_TEXT, qoute);

startActivity(Intent.createChooser(s, "Quote"));

最佳答案

这是官方 Facebook 应用程序中的错误。我必须使用适用于 Android 的 Facebook SDK 编写自己的 Activity 代码。请参阅下面的代码示例。

public class FacebookActivity extends Activity implements DialogListener
{

private Facebook facebookClient;
private LinearLayout facebookButton;
private final String APP_API_ID = "XXXXXXXX";


@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
facebookClient = new Facebook();
// replace APP_API_ID with your own
facebookClient.authorize(this, APP_API_ID,
new String[] {"publish_stream", "read_stream", "offline_access"}, this);


}

@Override
public void onComplete(Bundle values)
{

if (values.isEmpty())
{
//"skip" clicked ?

}

// if facebookClient.authorize(...) was successful, this runs
// this also runs after successful post
// after posting, "post_id" is added to the values bundle
// I use that to differentiate between a call from
// faceBook.authorize(...) and a call from a successful post
// is there a better way of doing this?
if (!values.containsKey("post_id"))
{
try
{
Bundle parameters = new Bundle();
parameters.putString("message", "YOUR TEXT TO SHARE GOES HERE");// the message to post to the wall
facebookClient.dialog(this, "stream.publish", parameters, this);// "stream.publish" is an API call


}
catch (Exception e)
{
// TODO: handle exception
System.out.println(e.getMessage());
}

}

}

@Override
public void onError(DialogError e)
{
return;
}

@Override
public void onFacebookError(FacebookError e)
{
return;
}

@Override
public void onCancel()
{
return;
}

}

关于安卓 Facebook Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3481079/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com