I am trying to use shareintent in my application, but I had a problem while sharing the facebook link, the preview images are not displayed. So I tried setting up android android to use the share functions from facebookdk when the facebook function is selected, but I can't get it to work. Below is the code I tried to set up shareintent,
Intent share = new Intent(android.content.Intent.ACTION_SEND); PackageManager pm = getPackageManager(); List<ResolveInfo> activityList = pm.queryIntentActivities(share, 0); for (final ResolveInfo app : activityList) { if (app.activityInfo.packageName.toLowerCase().startsWith("com.facebook.katana")) { ShareLinkContent content = new ShareLinkContent.Builder() .setContentTitle(property.PropertyName) .setImageUrl(Uri.parse(property.ImagePath)) .setContentUrl(Uri.parse(property.PropertyPermaLink)) .build(); ShareDialog shareDialog = new ShareDialog(this); shareDialog.canShow(content); break; } else { share.setType("text/plain"); share.addFlags(share.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); share.putExtra(Intent.EXTRA_SUBJECT, ""); share.putExtra(Intent.EXTRA_TEXT, property.PropertyPermaLink); startActivity(Intent.createChooser(share, "Share property!")); } }
After debugging the above code, I found that the activity list consists of only one element. So how can I solve this problem?
Shafayat mamun
source share