I put a button to share my Android app on Facebook, so I wrote the following code
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
// add the app link
intent.putExtra(Intent.EXTRA_TEXT, "http://play.google.com/store/apps/details? id=com.phonelight.realparrot");
startActivity(Intent.createChooser(intent, "Share with Facebook"));
After sharing, I opened my Facebook account and saw the following:
As you can see, It should be an image in the right square. I am wondering how can I put that image, I am thinking to put my icon app
Like if you share a youtube link, the image will be the first shot of the movie.
Change intent.setType("text/plain");
to intent.setType("image/*");
then add intent.putExtra(Intent.EXTRA_STREAM, myImageContentUri);
Related
I know this question has been asked many times and in many different ways (see here and here). However, I haven't been able to achieve it in the following way:
The picture and the title are in the same section. Then, there is the rest with the link in another section. I have achieved to put text and image together, but the picture is on the top of the text.
This is the code I am using:
Intent intent = new Intent();
intent.setComponent(new ComponentName(packageName, ri.activityInfo.name));
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, shareContentByWhatsapp(contentType));
intent.putExtra(Intent.EXTRA_STREAM, getImage());
intent.setType("image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Does anyone know how to obtain same result than in the picture?
As image you have shared,
In this case you just need to share the link,
image and link related content will be fetched by WhatsApp itself.
You can do like this:
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "http://www.google.com");
mContext.startActivity(whatsappIntent);
or, you can share image with caption.
But, image you have shared, is whatsapp's functionality :-)
I am send an Intent with the action Intent.ACTION_SEND. This works fine and the user can pick what application to share with and so on.
The issue is when they pick Facebook Messenger to share. All I get is a white, modal screen with "Send to" in the top left and a search icon in the top right.
Here is the code that launches the intent.
Intent appIntent = new Intent(Intent.ACTION_SEND);
appIntent.setType("text/plain");
appIntent.putExtra(Intent.EXTRA_TEXT,"Check out this app. \nhttp://www.boxshark.co.uk");
appIntent.putExtra(Intent.EXTRA_SUBJECT,"Get the Boxshark app");
startActivity(Intent.createChooser(appIntent,"Share"));
I get that Facebook don't allow pre filled text when you use the share intent so my "Check out this app" text is removed. I don't understand however why the Facebook Messenger app is not doing anything however.
Any ideas anyone? Can you see anything wrong with my intent?
PackageManager pm=getPackageManager();
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("image/jpeg");
Uri uri = Uri.parse("android.resource://1/"+2);
i.putExtra(Intent.EXTRA_STREAM, uri);
PackageInfo info=pm.getPackageInfo("com.facebook.orca", PackageManager.GET_META_DATA);
i.setPackage("com.facebook.orca");
startActivity(Intent.createChooser(i, "Share with"));
1.your package name display in 1st line of your file
2.your image int value from srting which want to share
"com.facebook.orca" is facebook massanger package
Its work for me,hope your also
put only link, do not add text with link.
appIntent.putExtra(Intent.EXTRA_TEXT,"http://www.boxshark.co.uk")
I could understand from various post that it is not possible to share both the image and text data in Facebook through intent share. But Twitter is able to share both thumbnail and text in Facebook through intent share which is shown in the image. SO can u comment on this and suggest a way to share both image and text in Facebook through intent.
Thanks in advance.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_TEXT, viewProject.getShareLink());
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, "compatible apps:"));
I am trying to share a text containing a link via facebook.
My code work perfectly with the facebook messenger application. But not via Facebook app.
In Facebook app i am getting a sharing view with an empty edittext. I Don't want to integrate facebook api and give sharing authorisation. I don't want to do that. I think it can be done only via extras and intent.
My sharing code:
private void ShareWebView(){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, mTitle);
startActivity(Intent.createChooser(intent, "Share with"));
}
You cannot. See Android and Facebook share intent
And especially this link provided in one of the comment : http://developers.facebook.com/bugs/332619626816423
Walkaround: If you do not want to implement it using android SDK
and you want to use
private void ShareWebView(){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, mTitle); // MUST contain 1 url
startActivity(Intent.createChooser(intent, "Share with"));
}
make sure that mTitle contains one LINK.
Why to do that: Although the fact that facebook doesn't work properly it grubs the first url or look like url from the mTitle and post-it as share url. It also automatically catch a subtitle and a photo from that url so the post/share is quite acceptable most of the time avoiding long code implementations!
i have Samsung Galaxy S. In the phone's gallery there is a share button. When you click the button, a menu contains share sites show up. You can pick one ot them and upload the picture. The best part of the menu; İf you download an application(for example facebook) into your phone, it appers in the menu. İ want to you use that function in my app. I will use camera, take picture and display on the imageview. And then i want to make a button like this one and share the photo. I am asking that because i download a gallery application which is not the native gallery of the phone, It also has the same button. Is there anyway that i can use it directly in my application. I dont want to use it after calling the gallery.
try this code
intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "try this application ");
intent.putExtra(Intent.EXTRA_TEXT, "https://market.android.com/details?id=com.music.player");
startActivity(Intent.createChooser(intent, "Share with"));
for more information check this link
This code will help you to redirect to native gallery in your device.
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");