I want to upload image to facebook or/and other services, and with , for example, what's up works fine, my picture is send to any contact i choose, but when i pick Facebook on dialog chooser it opens my Facebook App, but says "One or more media items could not be added"
Here is my code how i do it:
String file_path = Environment.getExternalStorageDirectory().getAbsolutePath()+"/image.jpg";
Uri imageUri = Uri.parse(file_path);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpg");
share.putExtra(Intent.EXTRA_STREAM, imageUri);
share.putExtra(Intent.EXTRA_TEXT, "My Image");
startActivity(Intent.createChooser(share, "Share Image"));
Related
I wanted to share my image to social site along with textlink and image , I am using below code , it does share Image but no text , Also I tried to set setype to "text/html" , it does not does what i need.
protected void onPostExecute(String args) {
// TODO Auto-generated method stub
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_TITLE, "http://www.google.com");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));
startActivity(Intent.createChooser(share, "Share Image"));
pDialog.dismiss();
}
Give this a try
Uri imageUri = Uri.parse(Filepath);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage("com.whatsapp");
shareIntent.putExtra(Intent.EXTRA_TEXT, "My sample image text");
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
try {
startActivity(shareIntent);
} catch (android.content.ActivityNotFoundException ex) {
ToastHelper.MakeShortText("Kindly install whatsapp first");
}
PS: For sharing in multiple apps just create an alert dialogue and add
whtsapp,fb and other sharing option and while clicking on them you
have to call specific intent for this.As per my knowledge for sharing
in facebook you must impliment it's sdk, though facebook is able to
share simple image and hyperlink without integrating sdk.
I use the code below for sharing images but unfortunately it works only for Line, not for Facebook and Viber
Code:
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/png");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(G.DIR_APP + "/sample_image.png"));
startActivity(Intent.createChooser(share, "Share image"));
Share directly to Facebook and Viber...
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/png");
share.setPackage("com.facebook.katana");
//for viber package is "com.viber.voip".
share.putExtra(Intent.EXTRA_STREAM, ImageUri);
startActivity(p_intent.createChooser(share, "Share With"));
I have developed one wallpaper application in which I want to add share button to share a photo on whatsapp. Here is my code( but that code is only for any text msg) I want to share a photo.
Please respond with the code where in I can select a wallpaper from my application and send to whatsapp's particular contact.
case R.id.save:
InputStream y11 = getResources().openRawResource(to);
Bitmap b11 = BitmapFactory.decodeStream(y11);
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("image/*");
waIntent.setPackage("com.whatsapp.android");
waIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, to);
startActivity(Intent.createChooser(waIntent, "Share with"));
Replace
waIntent.setType("text/plain");
with
waIntent.setType("image/png");
the package name is wrong. try: com.whatsapp
and this code is to share image via whatsapp
private void shareIt(Uri uri) {
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("image/*");
sharingIntent.setPackage("com.whatsapp");
sharingIntent.putExtra(Intent.EXTRA_TEXT,"Shared via my app");
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(sharingIntent, "share with"));
}
I am trying to attach an image from SD Card to an email (from my app to Gmail app).
Every time I try, I select Gmail app and it closes, it doesn't attach the file.
Let's say the image path is: /sdcard/DCIM/Snapseed/Snapseed4.jpg. This is the code I am using to send the email:
Intent emailintent2 = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailintent2.setType("image/*");
emailintent2.putExtra(Intent.EXTRA_EMAIL, emailaddress2);
emailintent2.putExtra(Intent.EXTRA_SUBJECT, CorAsunto);
emailintent2.putExtra(Intent.EXTRA_TEXT, message2);
Uri uris = Uri.fromFile(new File(Environment.getExternalStorageDirectory()
+ "/DCIM/Snapseed/Snapseed4.jpg"));
emailintent2.putExtra(Intent.EXTRA_STREAM, uris);
startActivity(emailintent2);
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
emailIntent.setType("image/jpeg");
emailIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("SDCARD IMAGE PATH"));
startActivity(Intent.createChooser(emailIntent,"Share image using"));
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"));