我有一个Android应用程序,它支持通过其他应用程序发送文本。因此,它使用ACTION_SEND
intent和EXTRA_TEXT
字段。chooser为我提供了所有可以处理这种意图的应用程序。有推特,电子邮件,..。还有脸书。但当我选择Facebook时,它会打开浏览器并进入以下页面:
http://m.facebook.com/sharer.php?u=mytext
它显示我的文本和提交按钮。但是,当我按下submit按钮时,没有任何反应。页面只是再次加载。我想可能只有通过Facebook App才能发送URL。会是这样吗?
有没有人设法通过Facebook的Android应用程序通过ACTION_SEND
发送短信?
发布于 2011-02-11 16:35:23
要使共享与facebook应用程序协同工作,您只需提供至少一个链接:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "Wonderful search engine http://www.google.fr/");
startActivity(Intent.createChooser(intent, "Share with"));
这将显示正确的分享窗口,但当你点击分享时,没有任何反应(我也尝试了官方Twitter应用程序,它不起作用)。
我发现让Facebook应用程序共享工作的唯一方法是只共享一个没有文本的链接:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "http://www.google.fr/");
startActivity(Intent.createChooser(intent, "Share with"));
它将显示以下窗口,并且共享按钮将起作用:
显然,它会自动从链接中获取图片和文本来填充共享。
如果您只想共享文本,则必须使用facebook api:https://github.com/facebook/facebook-android-sdk
发布于 2013-12-12 20:21:29
Check this out : By this we can check activity results also....
// Open all sharing option for user
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, ShortDesc+" from "+BusinessName);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, ShortDesc+" "+ShareURL);
sharingIntent.putExtra(Intent.EXTRA_TITLE, ShortDesc+" "+ShareURL);
startActivityForResult(Intent.createChooser(sharingIntent, "Share via"),1000);
/**
* Get the result when we share any data to another activity
* */
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case 1000:
if(resultCode == RESULT_OK)
Toast.makeText(getApplicationContext(), "Activity 1 returned OK", Toast.LENGTH_LONG).show();
else
Toast.makeText(getApplicationContext(), "Activity 1 returned NOT OK", Toast.LENGTH_LONG).show();
break;
case 1002:
if(resultCode == RESULT_OK)
Toast.makeText(getApplicationContext(), "Activity 2 returned OK", Toast.LENGTH_LONG).show();
break;
}// end switch
}// end onActivityResult
发布于 2016-12-08 00:23:51
ShareDialog shareDialog = new ShareDialog(this);
if(ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder().setContentTitle(strTitle).setContentDescription(strDescription)
.setContentUrl(Uri.parse(strNewsHtmlUrl))
.build();
shareDialog.show(linkContent);
}
https://stackoverflow.com/questions/3515198
复制相似问题