Note that there are some explanatory texts on larger screens.

plurals
  1. POClassCastException when starting E-Mail Intent
    primarykey
    data
    text
    <p>I'm trying to send an email using email intent. This is my code:</p> <pre><code>/** Called when the user clicks the send button */ public void cont_sendEmail(View view) { final EditText nick = (EditText) findViewById(R.id.contNick); final EditText feas = (EditText) findViewById(R.id.contFeas); final EditText tip = (EditText) findViewById(R.id.contTip); String totalNick = nick.getText().toString(); String totalFeas = feas.getText().toString(); String totalTip = tip.getText().toString(); String totalText = totalNick.concat(totalFeas); // Do something in response to button Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL , new String[]{"sando@live.se"}); i.putExtra(Intent.EXTRA_SUBJECT, "New contribution!"); i.putExtra(Intent.EXTRA_TEXT , totalText); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(ContributeActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } } </code></pre> <p>When I press the "send" button and activates cont_sendEmail, the app crashes. This is my logcat:</p> <pre><code>08-17 14:29:16.445: E/AndroidRuntime(12649): FATAL EXCEPTION: main 08-17 14:29:16.445: E/AndroidRuntime(12649): java.lang.IllegalStateException: Could not execute method of the activity 08-17 14:29:16.445: E/AndroidRuntime(12649): at android.view.View$1.onClick(View.java:3691) 08-17 14:29:16.445: E/AndroidRuntime(12649): at android.view.View.performClick(View.java:4211) 08-17 14:29:16.445: E/AndroidRuntime(12649): at android.view.View$PerformClick.run(View.java:17267) 08-17 14:29:16.445: E/AndroidRuntime(12649): at android.os.Handler.handleCallback(Handler.java:615) 08-17 14:29:16.445: E/AndroidRuntime(12649): at android.os.Handler.dispatchMessage(Handler.java:92) 08-17 14:29:16.445: E/AndroidRuntime(12649): at android.os.Looper.loop(Looper.java:137) 08-17 14:29:16.445: E/AndroidRuntime(12649): at android.app.ActivityThread.main(ActivityThread.java:4898) 08-17 14:29:16.445: E/AndroidRuntime(12649): at java.lang.reflect.Method.invokeNative(Native Method) 08-17 14:29:16.445: E/AndroidRuntime(12649): at java.lang.reflect.Method.invoke(Method.java:511) 08-17 14:29:16.445: E/AndroidRuntime(12649): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006) 08-17 14:29:16.445: E/AndroidRuntime(12649): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773) 08-17 14:29:16.445: E/AndroidRuntime(12649): at dalvik.system.NativeStart.main(Native Method) 08-17 14:29:16.445: E/AndroidRuntime(12649): Caused by: java.lang.reflect.InvocationTargetException 08-17 14:29:16.445: E/AndroidRuntime(12649): at java.lang.reflect.Method.invokeNative(Native Method) 08-17 14:29:16.445: E/AndroidRuntime(12649): at java.lang.reflect.Method.invoke(Method.java:511) 08-17 14:29:16.445: E/AndroidRuntime(12649): at android.view.View$1.onClick(View.java:3686) 08-17 14:29:16.445: E/AndroidRuntime(12649): ... 11 more 08-17 14:29:16.445: E/AndroidRuntime(12649): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText 08-17 14:29:16.445: E/AndroidRuntime(12649): at com.sandtdevelopment.getrich.ContributeActivity.cont_sendEmail(ContributeActivity.java:18) </code></pre> <p>(How do I paste the logcat to be readable?)</p> <p>What can be the problem?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload