On Sep 1, 10:58 am, "Dexter's Brain" <[email protected]> wrote:
> The Uri seems to be incorrect. "file://sdcard/myfile.zip"
>
> You can directly specify a file uri like Uri.fromFile(new File("/
> sdcard/myfile.zip"))
>
> Regards,
> Dexter.
>
> On Sep 1, 11:35 am, SrilankanKK <[email protected]> wrote:
>
> > Hi
>
> > I have create a zip file on the phone sdk. So i need to create a
> > program to attach that zip file and mail it. For that i need the uri
> > of that file. I used its physical path but it doesn't work.
>
> > path to the file - sdcard/myfile.zip
>
> > i used it in the code in foloowing way
>
> > sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://sdcard/
> > myfile.zip"));
>
> > when email is sent no attachment can be seen.
> > Is it a problem with a uri.
> > is it a problem with the MIME type
>
> > Thank in advance
>
>
Thank you for the reply. I tried with the Uri.fromfile() method. But
same thing happened.
What i need is
I need to send a five images attached to a one mail. I tried to do
it with intents but it fails. Now i am trying to zip those five images
to a one file and attach it to the mail.
cod eused to create zip file
String[] filenames = new String[] { imageUri1.getEncodedPath(),
imageUri2.getEncodedPath(), imageUri3.getEncodedPath(),
imageUri4.getEncodedPath(), imageUri5.getEncodedPath()
};
String outFilename = "outfile.zip";
byte[] buf = new byte[1024];
ZipOutputStream out = null;
try {
out = new ZipOutputStream(new FileOutputStream(outFilename));
// Compress the files
for (int i = 0; i < filenames.length; i++) {
FileInputStream in = new FileInputStream(filenames[i]);
// Add ZIP entry to output stream.
out.putNextEntry(new ZipEntry(filenames[i]));
// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
// Complete the entry
out.closeEntry();
in.close();
out.close();
}
} catch (Exception e) {
}
// Complete the ZIP file
i used intent to send the mail
String[] mailto = { "[email protected]" };
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent1.putExtra(Intent.EXTRA_EMAIL, mailto);
sendIntent1.putExtra(Intent.EXTRA_SUBJECT, "mail subject");
sendIntent1.setType("application/zip ");
sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File("/sdcard/
outfile.zip")));
startActivity(Intent.createChooser(sendIntent, "send the mail"));
what is the wrong with my code?
Is this possible with Android?
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---