I experiment out with Intent, to share text and image both. However, I realize sharing through intent is almost unusable, although my image size is less than 100kb. I experiment the following problem.
- GMail - OK
- Twitter - I can see there is text and picture in composer. However, I can never post successfully unless I remove the picture from composer. Not sure why. I only get message "Tweet not sent, saved to drafts."
- Facebook - Only picture. No text.
- Google Plus - I always get error message "Can't create post. Try again later."
- Yahoo Mail - No picture attachment.
I was wondering, whether you all encounter similar problem as mine? Do you guys solve this by using native API provided by Facebook and Twitter?
I just really figure out how my Intent sharing code can get wrong.
private void share() {
final String share_subject = getString(R.string.share_subject);
final String share_content = getString(R.string.share_content);
final String share_intent_title = getString(R.string.share_intent_title);
File file = mainView.getScreenshotFile();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_SUBJECT, share_subject);
intent.putExtra(Intent.EXTRA_TEXT, share_content);
// http://stackoverflow.com/questions/5214764/how-to-share-photo-with-caption-via-android-share-intent-on-facebook
intent.putExtra(Intent.EXTRA_TITLE, share_content);
// http://stackoverflow.com/questions/9023116/sharing-an-image-with-google-app-using-intent-action-send-and-intent-extra-stre
ContentValues values = new ContentValues(2);
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
values.put(MediaStore.Images.Media.DATA, file.getAbsolutePath());
Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
intent.putExtra(Intent.EXTRA_STREAM, uri);
//intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivity(Intent.createChooser(intent, share_intent_title));
}