Where should it be placed?

I also get size = 0 and then I get a error saying "file//: attachment
paths must point to file:///sdcard" Igonoring attachment file



On Apr 7, 11:11 pm, powder <jonas.hey...@gmail.com> wrote:
> Hi,
>
> Thanks so much Kumar!
>
> It turned out to be the placement of the line:
>
> sendIntent.setType("text/csv")
>
> Regards Jonas.
>
> On Apr 5, 2:43 pm, Kumar Bibek <coomar....@gmail.com> wrote:
>
>
>
> > public static void sendFile(Context context) {
> >                 File exportDir = new 
> > File(Environment.getExternalStorageDirectory(),
> >                                 "mydir");
> >                 if (!exportDir.exists()) {
> >                         exportDir.mkdirs();
> >                 }
> >                 String csvFile = exportDir + "/file.csv";
> >                 File file = new File(csvFile);
> >                 if (file.exists()) {
> >                         Intent sendIntent = new Intent(Intent.ACTION_SEND);
> >                         sendIntent.putExtra(Intent.EXTRA_SUBJECT, "CSV 
> > file");
> >                         sendIntent.setType("text/csv");
> >                         sendIntent.putExtra(Intent.EXTRA_STREAM, 
> > Uri.parse("file://"
> >                                         + 
> > Environment.getExternalStorageDirectory()
> >                                         + "/mydir/file.csv"));
> >                         sendIntent.putExtra(Intent.EXTRA_STREAM, Uri
> >                                         
> > .parse("file:///sdcard/mydir/file.csv"));
> >                         
> > context.startActivity(Intent.createChooser(sendIntent,
> >                                         "Send CSV file"));
> >                 } else {
> >                         Toast.makeText(context, "TTT", 
> > Toast.LENGTH_LONG).show();
> >                 }
>
> > This piece of code works fine. I got the mail with the attachment.
>
> > Thanks and Regards,
> > Kumar Bibek
>
> > On Apr 5, 5:31 pm, Kumar Bibek <coomar....@gmail.com> wrote:
>
> > > I will try this and let you know.
>
> > > Thanks and Regards,
> > > Kumar Bibek
>
> > > On Apr 2, 3:09 am, powder <jonas.hey...@gmail.com> wrote:
>
> > > > The logcat says:
>
> > > > ...
> > > > 04-01 18:33:06.230: INFO/ActivityManager(76): Starting activity:
> > > > Intent { act=android.intent.action.SEND typ=text/csv flg=0x3000000
> > > > cmp=com.google.android.gm/.ComposeActivityGmail (has extras) }
> > > > 04-01 18:33:06.290: INFO/ActivityManager(76): Starting activity:
> > > > Intent { act=android.intent.action.SEND typ=text/csv flg=0x2800000
> > > > cmp=com.google.android.gm/.ComposeActivity (has extras) }
> > > > 04-01 18:33:06.589: DEBUG/Gmail(4465): ComposeActivity added to
> > > > message:0 attachment:|file.csv|text/csv|0|text/csv|LOCAL_FILE|file:///
> > > > sdcard/mydir/file.csv size:0
> > > > 04-01 18:33:06.609: INFO/Gmail(4465): >>>>> Attachment uri:
> > > > file:///sdcard/mydir/file.csv
> > > > 04-01 18:33:06.609: INFO/Gmail(4465): >>>>>           type: text/csv
> > > > 04-01 18:33:06.609: INFO/Gmail(4465): >>>>>           name: file.csv
> > > > 04-01 18:33:06.609: INFO/Gmail(4465): >>>>>           size: 0
> > > > ...
>
> > > > and the file size is 0. My file is attached in the email as a file but
> > > > always with 0 bytes (my file is 510 bytes)?
>
> > > > On Apr 1, 1:27 pm, Kumar Bibek <coomar....@gmail.com> wrote:
>
> > > > > Some logcat logs will be helpful in trying to figure out what went
> > > > > wrong.
>
> > > > > Thanks and Regards,
> > > > > Kumar Bibek
>
> > > > > On Apr 1, 2:10 pm, powder <jonas.hey...@gmail.com> wrote:
>
> > > > > > Hi,
>
> > > > > > I never got this to work on a real device, got the email but no
> > > > > > attachment, also when installing K9 on a emulator and
> > > > > > then sending the email I see the mail in the outbox with a size of 0
> > > > > > bytes:
>
> > > > > > public static void sendFile(Context context) {
> > > > > >   File exportDir = new 
> > > > > > File(Environment.getExternalStorageDirectory(),
> > > > > > "mydir");
> > > > > >   if (!exportDir.exists()) {
> > > > > >     exportDir.mkdirs();
> > > > > >   }
> > > > > >   String csvFile = exportDir + "/file.csv";
> > > > > >   File file = new File(csvFile);
> > > > > >   if(file.exists()) {
> > > > > >     Intent sendIntent = new Intent(Intent.ACTION_SEND);
> > > > > >     sendIntent.putExtra(Intent.EXTRA_SUBJECT, "CSV file");
> > > > > >     sendIntent.setType("text/csv");
> > > > > >     //sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
> > > > > >     //sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" +
> > > > > > Environment.getExternalStorageDirectory() + "/mydir/file.csv"));
> > > > > >     sendIntent.putExtra(Intent.EXTRA_STREAM, 
> > > > > > Uri.parse("file:///sdcard/
> > > > > > mydir/file.csv"));
> > > > > >     context.startActivity(Intent.createChooser(sendIntent, "Send CSV
> > > > > > file"));
> > > > > >   } else {
> > > > > >     Util.displayToast(context, R.string.no_csv_file);
> > > > > >   }
>
> > > > > > }
>
> > > > > > Any help appreciated.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to