Android need to share Image and text together all social medias - android

need to share Image and text together all social medias I used this it only share the image on facebook
// Intent sharingIntent = new Intent(Intent.ACTION_SEND);
// Uri path = Uri.parse("android.resource://com.hunter99x/" + R.drawable.ninexgreen);
// Uri screenshotUri = Uri.parse(path.toString());
// sharingIntent.setType("image/*");
// sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
// sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
// startActivity(Intent.createChooser(sharingIntent, "Share image using"));

Related

How to share Image from intent as ACTION_SEND to other app

I would to share a picture to other app.I am viewing the image now through get it by intent from other activity.
by this code I get image:
final String imageurl = i.getStringExtra("Image");
And I viewing by Picasso:
Picasso.get().load(imageurl).into(prImg);
Now the question is how to share the displayed image to different applications through the following code:
// Share image
private void shareImage( ) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(sharingIntent, "Share Image Using"));
Or I have to use other code to do it?

How can i share text and image in Android

I want share my application's content (Text and Image) and for this issue, I wrote below codes:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(content) + "" +"\n\n" + "download us app from this link" + "\n\n" +"https://play.google.com/app/com.example.example");
startActivity(Intent.createChooser(sharingIntent, "select app ..."));
But in this code, I can just share text not sharing image! I want to share Text and Image.
For show Text and Image, I use Webview. I show image into text in webview.
How can I share Text and Image?
Below code is useful to share both text and images with other apps.
String imageToShare = "http://s1.dmcdn.net/hxdt6/x720-qef.jpg"; //Image You wants to share
String title = "Title to share"; //Title you wants to share
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, title);
shareIntent.setType("*/*");
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_TEXT, imageToShare);
startActivity(Intent.createChooser(shareIntent, "Select App to Share Text and Image"));
See below Code,
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_TEXT,"http://lorempixel.com/400/200/sports/1/");//your Image Url
startActivity(Intent.createChooser(intent, "Share Image"));
Add the URI of your image to the bundle (e.g. http://some.server.com/your_image.png), this will allow the same image to be found & used when the data is pulled out of the bundle.

android Share Intent not works for text and image both

Hi there is the code i used to share text and image :
Toast.makeText(App.getContext(), "Share", Toast.LENGTH_LONG).show();
Intent sharingIntent = null;
if(!image_resource.isEmpty()){
sharingIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
String imagePath = "SD-Card Path";
ExceptionHelpers.dLog("SHARE_LOG", "Share image path : " + imagePath);
ExceptionHelpers.dLog("SHARE_LOG", "Share image exist : " + (new File(imagePath).exists())); // It return 'true' on LogCat
if(new File(imagePath).exists()) {
ExceptionHelpers.dLog("SHARE_LOG", "Share image and text");
Uri imageUri = Uri.fromFile(new File(imagePath));
sharingIntent.setType("*/*"); // also 'image/*' tested and not works
sharingIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
}else{
ExceptionHelpers.dLog("SHARE_LOG", "Share text");
sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
}
}else {
ExceptionHelpers.dLog("SHARE_LOG", "Share text");
sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
}
String shareBody = ""+App.getString(R.string.this_text_shared_from)+" : "+App.getString(R.string.app_name)+" "+App.getString(R.string.share_text_2)+" \n "+
App.getString(R.string.share_about);
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "" + App.getString(R.string.app_name));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "" + App.getString(R.string.share_via)));
App is my custom class and App.getString is :
public static String getString(int resId){
return App.context.getString(resId);
}
it don't works well on Telegram, Gmail and same Apps And only share text with out Image
i found the answer for it, it work for me and i sent text and image both in one message to Telegram app.here is my code.
Intent intent = new Intent(Intent.ACTION_SEND);
packageName="org.telegram.messenger";
intent.setPackage(packageName);
//this is my art....
intent.setType("image/text/plain");
path=getBitMapPath();//this is path of image
uri = Uri.parse(path);
putExtra(Intent.EXTRA_STREAM, uri);
putExtra(Intent.EXTRA_TEXT, "hello telegram. i do it!");
ss = Intent.createChooser(intent, "hamid");
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
//addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(ss);
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
else
sharingIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
sharingIntent.setType("image/*");
sharingIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
sharingIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
getActivity().startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_using)));

Sharing image on facebook via Intent in eclipse

I am using the following code to share image to facebook but its not working.
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/png");
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("/sdcard/img1.png"));
startActivity(Intent.createChooser(share, "Share Image"));
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(path);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
One, it should be in this order just for readability and sensical reasons
you need to say what the error is...
NEVER hardcode the path to the image '/sdcard/img1.png' use getExternalStorageDirectory() instead

sharing video. mail going but no video in it

i want to share video from my application. It is giving option and when i select gmail. I am getting mail but there is no video in it. the code is as follow. can some one tell me what i did wrong in it ?
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
String path="/mnt/sdcard/DCIM/Camera/VID_19800115_233308.3gp";
Uri videoUri = Uri.parse(path);
sharingIntent.setType("video/*");
Log.i(TAG, "::onClick:" + "videoUri"+videoUri);
sharingIntent.putExtra(Intent.EXTRA_STREAM, videoUri);
startActivity(Intent.createChooser(sharingIntent, "Share Video using"));

Categories

Resources