I have created an application that gets the location information(latitude,longitude,altitude) and sends email using ACTION_SEND to some gmail account. But i am unable to send auto generated mail to that account. I need to send mail whenever the location changes. But my application is displaying the list of choosers available. Please give me some idea.
Asked
Active
Viewed 201 times
1
-
3Use [this](http://stackoverflow.com/a/2033124/940096) – Praveenkumar Aug 31 '12 at 07:37
-
@SpK Thanks for the response but that needs a button to be clicked for sending email right ? I need some idea to send email automatically whenever you run that application. – RBS Aug 31 '12 at 07:43
-
Yes, Instead of button click. Do the changes with your needs. Simply. :) – Praveenkumar Aug 31 '12 at 07:44
1 Answers
1
From you case, you need to send mail when your location has been changed right. So, you've onLocationChanged from you class. From, there you can use this example for sending mail.
For example,
public void onLocationChanged(Location loc)
{
// Call the GmailSender as per the example
try {
GMailSender sender = new GMailSender("username@gmail.com", "password");
sender.sendMail("This is Subject",
"This is Body",
"user@gmail.com",
"user@yahoo.com");
} catch (Exception e) {
Log.e("SendMail", e.getMessage(), e);
}
}
So, you can simply send the mail when your location will changed instead of sending mail through Button click.

Community
- 1
- 1

Praveenkumar
- 24,084
- 23
- 95
- 173