Android app problem when sending SMS to email

Asked

Viewed 358 times

2

I am new as Android programmer, 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);

    }

}

Canvas

<?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 sent that 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)

inserir a descrição da imagem aqui

i fill the data and generated error by clicking the button.

  • 1

    Your question is too wide, try to direct your question, worth your attempts and where you believe the mistake is...

  • better the title? has something else?

  • You registered the Activity in the androidmanifest.xml ?

  • yes, I registered yes

  • 1

    The type of Intent isn’t this wrong or was typing error here? Right wouldn’t be right message/rfc822?

2 answers

1

Friend, the error is in this code snippet:

intent.setType("menssage/rfc822");

The right thing would be this way:

intent.setType("message/rfc822");

0

Initialize Edittext variables inside the onCreate, that is to say:

@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);
}
  • did not work, and still continue with the same problem.

  • Just answer me one question! Have you ever tried to create an application on android that sent SMS to email? I’m sorry to ask, is because your answer gave the impression that I had no zeal for my case, as if it were a played answer.

  • yes @wladyband, I’ve done this countless times... I’m sorry if I left that impression, I just wanted to help! And good luck to be able to solve your problem..

  • Tairone Dias could help me by email, so I would send the compressed project to you so you can help me. if you’ve done it countless times you won’t mind helping me with a simple project like mine, right? my technical email

Browser other questions tagged

You are not signed in. Login or sign up in order to post.