Guest User

Untitled

a guest
Dec 20th, 2017
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. @Override
  2. protected String doInBackground(Void... params) {
  3.  
  4. try {
  5. GMailSender sender = new GMailSender("xxxx@gmail.com",
  6. "xxxxpassword");
  7. sender.sendMail("This is a testing mail",
  8. "This is Body of testing
  9. mail","oskr.developer1024@gmail.com",
  10. "oskr.developer1024@gmail.com") ;
  11.  
  12. } catch (Exception e) {
  13. Log.e("error", e.getMessage(), e);
  14. return "Email No Enviado";
  15. }
  16. return "Email Enviado";
  17. }
  18.  
  19. @Override
  20. protected void onPostExecute(String result) {
  21. Log.e("LongOperation",result+"");
  22. }
  23. @Override
  24. protected void onPreExecute() {
  25.  
  26. }
  27. @Override
  28. protected void onProgressUpdate(Void... values) {
  29. }
  30. }
  31.  
  32. String emailAccount = "";
  33. AccountManager accountManager = AccountManager.get(getApplicationContext());
  34. Account account = getAccount(accountManager);
  35. if (account != null) {
  36. emailAccount = account.name;
  37. }
  38.  
  39. private static Account getAccount(AccountManager accountManager) {
  40. Account[] accounts = accountManager.getAccountsByType("com.google");
  41. Account account;
  42. if (accounts.length > 0) {
  43. account = accounts[0];
  44. } else {
  45. account = null;
  46. }
  47. return account;
  48. }
Add Comment
Please, Sign In to add comment