-1
I have this error when sending email that occurs right in this code snippet. Basically it’s a form that receives two pieces of information and sends it to a predefined email.
java.lang.RuntimeException: Can't toast on a thread that has not called Looper.prepare()
at android.widget.Toast$TN.<init>(Toast.java:936)
at android.widget.Toast.<init>(Toast.java:205)
at android.widget.Toast.makeText(Toast.java:627)
at android.widget.Toast.makeText(Toast.java:588)
at br.com.cleiton.envioemail.MainActivity$2.run(MainActivity.java:69)
at java.lang.Thread.run(Thread.java:764)
new Thread(new Runnable(){
@Override
public void run() {
Mail m = new Mail();
String[] toArr = {email};
m.setTo(toArr);
m.setSubject(subject);
m.setBody(body);
try {
m.send();
} catch(RuntimeException rex) {
} catch(Exception e) {
e.printStackTrace();
System.exit(0);
}
Toast.makeText(getApplicationContext(), "Email enviado!", Toast.LENGTH_SHORT).show();
}
}).start();
What is the original error message? Post a stackTrace tbm, pf
– Gustavo