Domanda

I am using following code for fb share in android -

topics_fb_share.setOnClickListener(new OnClickListener(){
           @Override
           public void onClick(View v) {
               String urlToShare = "http://stackoverflow.com/questions/7545254";
               Intent intent = new Intent(Intent.ACTION_SEND);
               intent.setType("text/plain");
               // intent.putExtra(Intent.EXTRA_SUBJECT, "Foo bar"); // Has no effect!
               intent.putExtra(Intent.EXTRA_TEXT, urlToShare);
               // See if official Facebook app is found
               boolean facebookAppFound = false;
               List<ResolveInfo> matches = getPackageManager().queryIntentActivities(intent, 0);
               for (ResolveInfo info : matches) {
                   if (info.activityInfo.packageName.toLowerCase().startsWith("com.facebook")) {
                       intent.setPackage(info.activityInfo.packageName);
                       facebookAppFound = true;
                       break;
                   }
               }

               // As fallback, launch sharer.php in a browser
               if (!facebookAppFound) {
                   String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + urlToShare;
                   intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
               }
               startActivity(intent);
              }
    });

how can I add Title, Description and Image with this thanks in advance

È stato utile?

Soluzione

You can add image by this

intent .setAction(Intent.ACTION_SEND);
intent .putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media
.insertImage(getContentResolver(), source, title, description)));
intent .setType("image/jpeg");
startActivity(Intent.createChooser(shareIntent,
getResources().getString(R.string.send_to)));
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top