Skip to main content
2 de 2
correção do titulo da postagem
user avatar
user avatar

Problema app Android ao enviar SMS para email

Sou novo como programador Android, fiz o seguinte aplicativo;

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);

    }

}

Tela

<?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>

quando eu cliquei no botão emitiu essa mensagem de erro

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)

inserir a descrição da imagem aqui

eu preenchir os dados e gerou erro ao clicar no botão.

user10264