I want to share an animated gif file with telegram. I'm using following code:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/gif");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment
.getExternalStorageDirectory()
+ FOLDER_NAME
+ fileName + ".gif"));
share.setPackage("org.telegram.messenger");
startActivity(share);
this code open telegram but when I select a chat; there is not any thing to share.
Excuse me for bad English.
I solved it by changing code to
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/gif");
String imagePath = Environment
.getExternalStorageDirectory()
+ FOLDER_NAME
+ fileName + ".gif";
File imageFileToShare = new File(imagePath);
Uri uri = Uri.fromFile(imageFileToShare);
share.putExtra(Intent.EXTRA_STREAM, uri);
share.setPackage("org.telegram.messenger");
startActivity(share);
Related
i want to share audio file with social media like whatsapp,drive,gmail,etc.
i tried this code,
after i click on the whatsapp icon i get the massage:
"the file format is not supported"
after i click on the gmail icon i get the massage:
"Couldnt attach file"
//sharePath: my audio path file
String sharePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + songNameAndDateArray.get(newI).getSongName().toString() + "FinalSongRec" + "File" + "AudioRecording.3gp";
File f = new File(sharePath);
Uri uri = Uri.parse(f.getAbsolutePath());
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("audio/*");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent,"share audio");
Check following code
String sharePath = Environment.getExternalStorageDirectory().getPath()
+ "/Soundboard/Ringtones/custom_ringtone.ogg";
Uri uri = Uri.parse(sharePath);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("audio/*");
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Sound File"));
I found this answer from following link Sharing audio file
I want to share my csv file to any action like Bluetooth, send to email ,etc
final String filename = Environment.getExternalStorageDirectory() + "/Folder" + "/" + "mycsv.csv";
Intent sharingIntent = new Intent();
sharingIntent.setAction(Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_STREAM, filename);
sharingIntent.setType("text/comma_separated_values/csv");
startActivity(Intent.createChooser(sharingIntent, "share file with"));
the output will be no request containt no data
I think that the filename requires a file:// prefix. Android, for sharing any types of file requires a universal identifier or a Uri.
final String fileUriString = "file://" + Environment.getExternalStorageDirectory() + "/Folder" + "/" + "mycsv.csv";
Also, change the type to text/csv.
Intent sharingIntent = new Intent();
sharingIntent.setAction(Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse( fileUriString ) ) ;
sharingIntent.setType("text/csv");
startActivity(Intent.createChooser(sharingIntent, "share file with"));
See this answer for more.
How i can send the txt file that i created with the FileOutputStream trought of screemShare
i can also not found the file path
//x = "/data/data/" + getPackageName() +"/pec.txt";
this is my code:
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
Uri uri = Uri.parse(x);
intent.putExtra(android.content.Intent.EXTRA_STREAM, uri);
intent.putExtra(android.content.Intent.EXTRA_TEXT, "PEC");
startActivity(Intent.createChooser(intent,"Imprimir"));
Check this example that work for me HERE
I am sending a mail by using below code and i need to send a .text file also using gmail only.
How can i do it? Please can any one help me?
Intent send = new Intent(Intent.ACTION_SENDTO);
String uriText = "mailto:" + Uri.encode("") +
"?subject=" + Uri.encode("Sample Text") +
"&body=" + Uri.encode("Hi");
Uri uri = Uri.parse(uriText);
send.setData(uri);
startActivity(Intent.createChooser(send, "Send mail..."));
Thanking in Advance.
File sd = Environment.getExternalStorageDirectory();
File fileDir= new File(sd, "dir_path");
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_STREAM, Uri.parse(fileDir.getAbsolutePath() + "/"
+ FILE_TXT
startActivity(Intent.createChooser(email , "Email: Text File"));
I'm trying to share an image trough a share intent like this:
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("image/png");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, application.getString(R.string.app_name));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,application.getString(R.string.app_share_message));
File image = new File(Uri.parse("android.resource://" + C.PROJECT_PATH + "/drawable/" + R.drawable.icon_to_share).toString());
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
shareMe(sharingIntent);
The share intent fires correctly and I choose Gmail, everything runs as expected until I press send. I receive a notification "Unable to show attach", and the e-mail is sent without it...
Why?
Thanks for your time.
First, there is no guarantee that any given other app will be able to support an android:resource// Uri. You will have greater compatibility sharing a file on external storage or using a ContentProvider.
That being said, replace:
File image = new File(Uri.parse("android.resource://" + C.PROJECT_PATH + "/drawable/" + R.drawable.icon_to_share).toString());
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(image));
with:
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://" + C.PROJECT_PATH + "/drawable/" + R.drawable.icon_to_share);
An android:resource:// is not a File, and probably you are messing up your Uri by converting to a File and then back to a Uri.
BitmapDrawable bitmapDrawable = (BitmapDrawable)ImageView.getDrawable();
Bitmap bitmap = bitmapDrawable.getBitmap();
// Save this bitmap to a file.
File cache = getApplicationContext().getExternalCacheDir();
File sharefile = new File(cache, "toshare.png");
Log.d("share file type is", sharefile.getAbsolutePath());
try {
FileOutputStream out = new FileOutputStream(sharefile);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
} catch (IOException e) {
Log.e("ERROR", String.valueOf(e.getMessage()));
}
// Now send it out to share
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("image/*");
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://" + sharefile));
startActivity(Intent.createChooser(share,
"Share Image"));
In my case I used:
Uri imageUri = Uri.parse("android.resource://com.examle.tarea/" + R.drawable.tienda_musica);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(intent, getString(R.string.action_share)));
//open a share intent chooser (Will show installed app from which i can share //images)
private void shareImage(String imagePath, String quoteByPerson, String quoteToShare)
{
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
// String imagePath = Environment.getExternalStorageDirectory() +
// "/myImage.png";
File imageFileToShare = new File(imagePath);
Uri uri = Uri.fromFile(imageFileToShare);
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
share.putExtra(Intent.EXTRA_TEXT, "Quote of the day-:" + "\n" + quoteToShare + "\n" + quoteByPerson);
share.putExtra(android.content.Intent.EXTRA_TITLE, "Quote of the day-:");
if (imagePath.contains("android.resource://"))
{
Uri imageUri = Uri.parse(imagePath);
share.putExtra(Intent.EXTRA_STREAM, imageUri);
} else
{
share.putExtra(Intent.EXTRA_STREAM, uri);
}
startActivity(Intent.createChooser(share, "Share inspiration via..."));
}