Android 在Facebook上分享图片+;安卓应用程序链接

Android 在Facebook上分享图片+;安卓应用程序链接,android,facebook,image,hyperlink,share,Android,Facebook,Image,Hyperlink,Share,我有一个应用程序,可以让用户在facebook上共享图像;我想自动应用程序的链接可以与图像一起共享 这是我正在使用的代码,但是带有链接的部分被忽略,并且没有显示: Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("image/png"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(i

我有一个应用程序,可以让用户在facebook上共享图像;我想自动应用程序的链接可以与图像一起共享

这是我正在使用的代码,但是带有链接的部分被忽略,并且没有显示:

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
shareIntent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com"); //doesn't appear
PackageManager pm = context.getPackageManager();
List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
for (final ResolveInfo app : activityList)
{

    Log.d("CitationsManager-ShareOnFb", app.activityInfo.name);
    if ((app.activityInfo.name).contains("facebook.katana")
        || (app.activityInfo.name).contains("facebook.composer.shareintent")
        || (app.activityInfo.name).contains("facebook.composer.activity"))
    {
        final ActivityInfo activity = app.activityInfo;
        final ComponentName name = new ComponentName(
            activity.applicationInfo.packageName, activity.name);
        shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
            | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
            | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        shareIntent.setComponent(name);
        context.startActivity(shareIntent);
        break;
    }
Intent shareIntent=newintent(android.content.Intent.ACTION\u SEND);
setType(“image/png”);
shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(新文件(imagePath));
shareIntent.putExtra(Intent.EXTRA_TEXT,“http://www.google.com"); //没有出现
PackageManager pm=context.getPackageManager();
List activityList=pm.querytentActivities(shareIntent,0);
对于(最终解决方案信息应用程序:activityList)
{
Log.d(“引文管理器ShareOnFb”,app.activityInfo.name);
if((app.activityInfo.name).contains(“facebook.katana”)
||(app.activityInfo.name).包含(“facebook.composer.shareintent”)
||(app.activityInfo.name).包含(“facebook.composer.activity”))
{
最终活动信息活动=app.ActivityInfo;
最终组件名称=新组件名称(
activity.applicationInfo.packageName、activity.name);
shareIntent.addCategory(Intent.CATEGORY_启动器);
shareIntent.setFlags(Intent.FLAG\u活动\u新任务
|Intent.FLAG\活动\重置\任务\如果需要
|意图。标记活动(清除顶部);
setComponent(名称);
背景。开始触觉(共享意图);
打破
}
你知道我怎样才能得到结果吗?我已经读过关于这个主题的问题,但找不到合适的解决方案


谢谢

Facebook提供了shareDialog类在Facebook上共享图像或内容。您可以阅读更多详细信息,请查看


我也有类似的要求。你有相同的解决方案吗?
     shareDialog = new ShareDialog(this);  // initialize facebook shareDialog.
    button.setOnClickListener(new View.OnClickListener() {
    @Override
   public void onClick(View v) {
   if (ShareDialog.canShow(ShareLinkContent.class)) {
         ShareLinkContent linkContent = new ShareLinkContent.Builder()
             .setContentTitle("Android Facebook Integration and Login Tutorial")
             .setImageUrl(Uri.parse("https://www.studytutorial.in/
                   wp-content/uploads/2017/02/FacebookLoginButton-min-300x136.png"))
             .setContentDescription(
                     "This tutorial explains how to integrate Facebook and Login 
                     through Android Application")
             .setContentUrl(Uri.parse("https://www.studytutorial.in/
                         android-facebook-integration-and-login-tutorial"))
             .build();
                shareDialog.show(linkContent);  // Show facebook ShareDialog
       }
    }
});