Android 安卓Facebook意图
我正在使用此代码在Facebook上发布,但它与Facebook官方应用程序不兼容,因为它试图以链接形式发送。这有什么办法吗Android 安卓Facebook意图,android,facebook,Android,Facebook,我正在使用此代码在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
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官方应用程序中的一个漏洞。我必须编写自己的活动代码,才能使用FacebookSDK进行Android操作。请参阅下面的代码示例
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应用程序时,它会打开,但是额外的文本字段是一个共享URL而不是共享的消息吗。我利用这个意图通过短信、电子邮件、推特、facebook等分享文本。。。。问题是,如果我从弹出选择中选择facebook,“额外文本,qoute”字符串将作为facebook的url共享。这只会发生在开发人员“facebook”的facebook应用程序中。