Re: [android-developers] Re: Sending email with attachment

2010-04-26 Thread andy
Hi,

I want to receive Intent "android.intent.action.SEND" in a Service. Is it
possilbe to register for this Intent via registerReceiver() and get the
Intent in Broadcast receiver in the Service?

Or is there any restrictions that "android.intent.action.SEND" can only be
registered via Manifest.xml of an Activity and not in a Service?

On Fri, Apr 16, 2010 at 9:03 PM, powder  wrote:

>
> Sorry for not responding earlier. This worked for me:
>
>public static void sendFile(Context context) {
>String emailPreference =
>
> PreferenceManager.getDefaultSharedPreferences(context).getString("emailPreference",
> "");
>String subjectPreference =
>
> PreferenceManager.getDefaultSharedPreferences(context).getString("subjectPreference",
> "");
>String bodyPreference =
>
> PreferenceManager.getDefaultSharedPreferences(context).getString("bodyPreference",
> "");
>if(subjectPreference.length() == 0) {
>subjectPreference = (String)
> context.getText(R.string.csv_subject);
>}
>String csvFile = getFilename();
>File file = new File(csvFile);
>if(file.exists()) {
>Intent sendIntent = new Intent(Intent.ACTION_SEND);
>sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]
> {emailPreference});
>sendIntent.putExtra(Intent.EXTRA_SUBJECT,
> subjectPreference);
>sendIntent.putExtra(Intent.EXTRA_TEXT,
> bodyPreference);
>sendIntent.setType("text/csv");
>sendIntent.putExtra(Intent.EXTRA_STREAM,
> Uri.fromFile(new
> File(csvFile)));
>
>  context.startActivity(Intent.createChooser(sendIntent,
> context.getText(R.string.csv_send)));
>} else {
>Util.displayToast(context, R.string.no_csv_file);
>}
>}
>
> On Apr 14, 10:18 am, Scout Ma  wrote:
> > Thanks for your help.
> > I want to write an application which will send email with an
> > attachment through GMail on Android.
> > But I don't have much time to study the basic of JavaMail.
> > So, I wonder is there any sample for me to get in quickly.
> >
> > 2010/4/14 Kumar Bibek 
>  >
> > So, you want to learn how to create an email app? It depends actually
> > on the protocol that you want to work with. For POP and IMAP, there
> > are libraries which you have to use. Check out Java Mail API for this.
>
> --
> 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
>

-- 
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

[android-developers] Re: Sending email with attachment

2010-04-16 Thread powder

Sorry for not responding earlier. This worked for me:

public static void sendFile(Context context) {
String emailPreference =
PreferenceManager.getDefaultSharedPreferences(context).getString("emailPreference",
"");
String subjectPreference =
PreferenceManager.getDefaultSharedPreferences(context).getString("subjectPreference",
"");
String bodyPreference =
PreferenceManager.getDefaultSharedPreferences(context).getString("bodyPreference",
"");
if(subjectPreference.length() == 0) {
subjectPreference = (String)
context.getText(R.string.csv_subject);
}
String csvFile = getFilename();
File file = new File(csvFile);
if(file.exists()) {
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]
{emailPreference});
sendIntent.putExtra(Intent.EXTRA_SUBJECT, 
subjectPreference);
sendIntent.putExtra(Intent.EXTRA_TEXT, bodyPreference);
sendIntent.setType("text/csv");
sendIntent.putExtra(Intent.EXTRA_STREAM, 
Uri.fromFile(new
File(csvFile)));
context.startActivity(Intent.createChooser(sendIntent,
context.getText(R.string.csv_send)));
} else {
Util.displayToast(context, R.string.no_csv_file);
}
}

On Apr 14, 10:18 am, Scout Ma  wrote:
> Thanks for your help.
> I want to write an application which will send email with an
> attachment through GMail on Android.
> But I don't have much time to study the basic of JavaMail.
> So, I wonder is there any sample for me to get in quickly.
>
> 2010/4/14 Kumar Bibek 
>
> So, you want to learn how to create an email app? It depends actually
> on the protocol that you want to work with. For POP and IMAP, there
> are libraries which you have to use. Check out Java Mail API for this.

-- 
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


[android-developers] Re: Sending email with attachment

2010-04-14 Thread Scout Ma
Thanks for your help.
I want to write an application which will send email with an
attachment through GMail on Android.
But I don't have much time to study the basic of JavaMail.
So, I wonder is there any sample for me to get in quickly.


2010/4/14 Kumar Bibek 

So, you want to learn how to create an email app? It depends actually
on the protocol that you want to work with. For POP and IMAP, there
are libraries which you have to use. Check out Java Mail API for this.

-- 
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.


[android-developers] Re: Sending email with attachment

2010-04-13 Thread robl2e

@powder

Where should the setType() be placed then.  I'm having difficulties
getting this to work.


Thanks in advance.
On Apr 7, 2:11 pm, powder  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  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 theattachment.
>
> > Thanks and Regards,
> > Kumar Bibek
>
> > On Apr 5, 5:31 pm, Kumar Bibek  wrote:
>
> > > I will try this and let you know.
>
> > > Thanks and Regards,
> > > Kumar Bibek
>
> > > On Apr 2, 3:09 am, powder  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=0x300
> > > > 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=0x280
> > > > cmp=com.google.android.gm/.ComposeActivity (has extras) }
> > > > 04-01 18:33:06.589: DEBUG/Gmail(4465): ComposeActivity added to
> > > > message:0attachment:|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): >Attachmenturi:
> > > > 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 theemailas a file but
> > > > always with 0 bytes (my file is 510 bytes)?
>
> > > > On Apr 1, 1:27 pm, Kumar Bibek  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  wrote:
>
> > > > > > Hi,
>
> > > > > > I never got this to work on a real device, got theemailbut no
> > > > > >attachment, also when installing K9 on a emulator and
> > > > > > thensendingtheemailI 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 t

[android-developers] Re: Sending email with attachment

2010-04-08 Thread Ferm
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  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  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  wrote:
>
> > > I will try this and let you know.
>
> > > Thanks and Regards,
> > > Kumar Bibek
>
> > > On Apr 2, 3:09 am, powder  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=0x300
> > > > 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=0x280
> > > > 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  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  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 th

[android-developers] Re: Sending email with attachment

2010-04-07 Thread powder

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  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  wrote:
>
>
>
> > I will try this and let you know.
>
> > Thanks and Regards,
> > Kumar Bibek
>
> > On Apr 2, 3:09 am, powder  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=0x300
> > > 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=0x280
> > > 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  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  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.


[android-developers] Re: Sending email with attachment

2010-04-05 Thread Kumar Bibek
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  wrote:
> I will try this and let you know.
>
> Thanks and Regards,
> Kumar Bibek
>
> On Apr 2, 3:09 am, powder  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=0x300
> > 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=0x280
> > 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  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  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.


[android-developers] Re: Sending email with attachment

2010-04-05 Thread Kumar Bibek
I will try this and let you know.

Thanks and Regards,
Kumar Bibek

On Apr 2, 3:09 am, powder  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=0x300
> 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=0x280
> 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  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  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.


[android-developers] Re: Sending email with attachment

2010-04-01 Thread powder

The logcat says:

...
04-01 18:33:06.230: INFO/ActivityManager(76): Starting activity:
Intent { act=android.intent.action.SEND typ=text/csv flg=0x300
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=0x280
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  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  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.


[android-developers] Re: Sending email with attachment

2010-04-01 Thread Kumar Bibek
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  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.