Android app problem sending SMS to email

2

I'm new to Android developer, I made the following application;

package br.com.google.email;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.example.sms.R;

public class EnviarSMS extends Activity implements OnClickListener {
    private static final String CATEGORIA = "livro";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.form_enviar_sms);
        Button btEnviar = (Button) findViewById(R.id.btEnviar);

        btEnviar.setOnClickListener(this);
    }

    public void onClick(View v) {
        EditText EditTitulo = (EditText) findViewById(R.id.titulo);
        String titulo = EditTitulo.getText().toString();

        EditText EditMensagem = (EditText) findViewById(R.id.mensagem);
        String mensagem = EditMensagem.getText().toString();

        EditText EdiEmail = (EditText) findViewById(R.id.email);
        String emailAddresses = EdiEmail.getText().toString();

        Intent emailItent = new Intent(Intent.ACTION_SEND);
        emailItent.putExtra(Intent.EXTRA_SUBJECT, titulo );
        emailItent.putExtra(Intent.EXTRA_TEXT, mensagem );
        emailItent.putExtra(Intent.EXTRA_EMAIL, emailAddresses );
        emailItent.setType("menssage/rfc822");
        startActivity(emailItent);

    }

}

Screen

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Titulo" />

    <EditText 
        android:id="@+id/titulo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=""/>


    <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Email"/>

    <EditText 
        android:id="@+id/email"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=""/>


     <TextView 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Mensagem"/>
     <EditText 
        android:id="@+id/mensagem"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=""/>

    <Button 
        android:id="@+id/btEnviar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Enviar SMS"/>


</LinearLayout>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.sms"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:label="@string/app_name" android:name="br.com.google.email.EnviarSMS">
            <intent-filter >
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

When I clicked on the button I issued this error message

11-26 13:21:46.865: E/AndroidRuntime(793): FATAL EXCEPTION: main
11-26 13:21:46.865: E/AndroidRuntime(793): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=menssage/rfc822 flg=0x1 (has clip) (has extras) }
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.app.Activity.startActivityForResult(Activity.java:3370)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.app.Activity.startActivityForResult(Activity.java:3331)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.app.Activity.startActivity(Activity.java:3566)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.app.Activity.startActivity(Activity.java:3534)
11-26 13:21:46.865: E/AndroidRuntime(793):     at br.com.google.email.EnviarSMS.onClick(EnviarSMS.java:41)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.view.View.performClick(View.java:4204)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.view.View$PerformClick.run(View.java:17355)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.os.Handler.handleCallback(Handler.java:725)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.os.Looper.loop(Looper.java:137)
11-26 13:21:46.865: E/AndroidRuntime(793):     at android.app.ActivityThread.main(ActivityThread.java:5041)
11-26 13:21:46.865: E/AndroidRuntime(793):     at java.lang.reflect.Method.invokeNative(Native Method)
11-26 13:21:46.865: E/AndroidRuntime(793):     at java.lang.reflect.Method.invoke(Method.java:511)
11-26 13:21:46.865: E/AndroidRuntime(793):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-26 13:21:46.865: E/AndroidRuntime(793):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-26 13:21:46.865: E/AndroidRuntime(793):     at dalvik.system.NativeStart.main(Native Method)

I fill in the data and generated error when clicking the button.

    
asked by anonymous 26.11.2014 / 15:06

2 answers

1

Friend, the error is in this snippet of code:

intent.setType("menssage/rfc822");

The correct way would be this:

intent.setType("message/rfc822");
    
06.01.2017 / 03:06
0

Initialize the EditText variables within onCreate , that is:

@Override

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.form_enviar_sms);

    Button btEnviar = (Button) findViewById(R.id.btEnviar);

    EditText EditTitulo = (EditText) findViewById(R.id.titulo);

    EditText EditMensagem = (EditText) findViewById(R.id.mensagem);

    EditText EdiEmail = (EditText) findViewById(R.id.email);

    btEnviar.setOnClickListener(this);
}
    
26.11.2014 / 15:51