I have the following code in Android that programmatically adds a set of photos to a post that will be shared on Google+:
private void shareToGooglePlus() {
// Launch the Google+ share dialog with attribution to your app.
PlusShare.Builder share = new PlusShare.Builder(this);
for (String imageFilename : imageList) {
Uri imageUri = Uri.fromFile(new File(imageFilename));
share.addStream(imageUri);
}
share.setText("My images");
share.setType("image/jpeg");
startActivityForResult(share.getIntent(), 0);
}
Since I have a bunch of different images, I would like to add captions to each to describe what is in each picture. However, I can't seem to find a way to do that in with PlusShare.Builder. Does anyone know if it is possible and how to do it?
Thanx in advance.
That can't be done with PlusShare - the text refers to the primary post only.
Related
I want the user to be able to share a link (to text content online). When shared, I also want a link to the app in the Play Store to appear below said link.
Via email, the shared might look like the following
Email subject: [content subject]
Email body:
[link to content]
Download our app here:
[link to app in Play Store]
I tried something like this, but it doesn't display the links:
String playStoreUrl = "market://details?id=" + getActivity().getApplicationContext().getPackageName();
ArrayList<String> links = new ArrayList<String>();
links.add(data.getLink());
links.add(playStoreUrl);
Intent sharingIntent2 = new Intent(Intent.ACTION_SEND_MULTIPLE);
sharingIntent2.putExtra(Intent.EXTRA_SUBJECT, content.getSubject());
sharingIntent2.putStringArrayListExtra(Intent.EXTRA_TEXT, links);
sharingIntent2.setType("text/plan");
startActivity(Intent.createChooser(sharingIntent2, "Share this content"));
Any help is much appreciated! There doesn't seem to much documentation on this.
You can do it like this:
String YOUR_TEXT_TO_SEND=data.getLink()+"\n"+"Download our app here: "+"[link to app in Play Store]";
intent.putExtra(Intent.EXTRA_TEXT, YOUR_TEXT_TO_SEND);
What is the correct way to share an image and text to Facebook in android?
e.g. picture with pre-populated text.
I realise that this is not possible from the native Android share intent as described here. As it can only take an image or a link not both.
Also I have tried using the facebook-sdk-3.14 with:
FacebookDialog.ShareDialogBuilder
but I now realise this is for sharing links only.
I have also tried with:
createShareDialogBuilderForPhoto()
but this is for sharing images only.
Is there something I am missing in the sdk? I am guessing it is not possible from FacebookDialog?
Will I need to go the route of creating my own app in facebook and my own open graph action? Ideally I am looking to not have a login button.
I have also seen similar questions but most are about the share intent or if it is the sdk it at least a year out of date and the solution is some thing similar to this:
Bundle parameters = new Bundle();
parameters.putString("message", category_item_name_desc.getText().toString());
parameters.putString("picture", categoryItemsModel.getImageUrl());
parameters.putString("caption", txtDescription_desc.getText().toString());
facebook.request("/me/feed", parameters, "POST");
Tried it through the Feed Dialog (WebDialog) but im getting a "error (#324) requires upload file", Any help would be great.
You can share your image on facebook, Twitter, and Gmail:
Bitmap b =BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType(“image/jpeg”);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
String path = MediaStore.Images.Media.insertImage(getContentResolver(), b, “Title”, null);
Uri imageUri = Uri.parse(path);
share.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(share, “Select”));
Was able to do this my self with the current Facebook SDK (3.14.1 at the time) with no login and I made it into a share intent for adding to the chooser list.
I have a demo project at https://github.com/b099l3/FacebookImageShareIntent only dependency is the facebook sdk and it is contained in one activity.
Please take a look a look on my library: https://github.com/antonkrasov/AndroidSocialNetworks
With help of it, posting is really easy:
mSocialNetworkManager.getFacebookSocialNetwork().postMessage(String message)
mSocialNetworkManager.getFacebookSocialNetwork().postPhoto(File path...)
I have programmatically added Google+ sharing to my app. I have a set of photos that I include with my posts and share with the following code:
private void shareToGooglePlus() {
// Launch the Google+ share dialog with attribution to your app.
PlusShare.Builder share = new PlusShare.Builder(this);
for (String imageFilename : imageList) {
Uri imageUri = Uri.fromFile(new File(imageFilename));
share.addStream(imageUri);
}
share.setText("My images");
share.setType("image/jpeg");
startActivityForResult(share.getIntent(), 0);
}
When this code gets executed, the Google+ app on my phone is started and I get a preview that has the images and text as expected.
However, if I run this more than once and include different images on subsequent runs, the original images show up in the Google+ post preview instead of the new ones. If I submit the post, the correct images show up in the post--the new ones, not the original ones.
I presume the Google+ app has some kind of caching mechanism. Is there a way to programmatically clear that cache so that the correct images show up in the Google+ app post preview?
Thanx in advance.
Try assigning different random names to your source files (by renaming or copying) on each run
Am doing photo sharing in my application.for that am using Adding an Easy Share Action.it show only icon in the action bar,not options.so please suggest me with some example.
http://developer.android.com/training/sharing/shareaction.html
Easy Share is auto-populating; you only need to tell the ShareActionProvider what content it is you will be sharing.
Most of this is shared in the API link you provided, but if you are aiming to populate the list for the images you aim to be sharing, you would need to include this.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
Uri uri = Uri.fromFile(new File(getFilesDir(), "foo.jpg"));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri.toString());
Now that the shareIntent has been set to image, it will populate the list with the related apps, such as instagram, facebook or PhotoShop.
The app will view the images as a MIME type (Multipurpose Internet Mail Extension) in one of the types found here when you call shareIntent.setType.
I can easily share a text in Google+ but when i want to add a picture with the text, i got this message ;
You can only post media items stored in your device.
Here is my code:
Uri uri = Uri.parse("android.resource://com.smurf.fapiao/" + R.drawable.myimage);
// Launch the Google+ share dialog with attribution to your app.
Intent shareIntent = new PlusShare.Builder(getActivity())
.setType("image/png").setStream(uri)
.setText(getString(R.string.social_googleplus_text) + " http://www.wangwanglotto.com")
.getIntent();
startActivityForResult(shareIntent, 0);
Do you have any idea ? I tried to put the file in raw or assets folder, but i still get the message.
Thanks in advance