Created
January 2, 2022 14:08
-
-
Save RohanNavlakhe2/d37809fcf211741393187ccb437f7462 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String[] emailContent = {"Hii Abhi!","Here is my new article","[email protected]"}; | |
Observable.just(emailContent) | |
.map(emailData -> { | |
GMailSender sender = new GMailSender("[email protected]", | |
"password"); | |
sender.sendMail(emailData[0], emailData[1], | |
"senderemailid",emailData[2]); | |
return "Email Successfully sent"; | |
}) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribeOn(Schedulers.io()) | |
.subscribe(new DisposableObserver<String>() { | |
@Override | |
public void onNext(String s) { | |
//s wil contain what map() will return | |
Toast.makeText(context, s , Toast.LENGTH_SHORT).show(); | |
} | |
@Override | |
public void onError(Throwable e) { | |
Toast.makeText(context,"Email Send failed", Toast.LENGTH_SHORT).show(); | |
} | |
@Override | |
public void onComplete() { | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment