Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Dúvida no Ex. 3 da Aula 1 - Completando nosso sistema: Intents

O seguinte codigo mostrado como exemplo não funcionou:

    MenuItem email = menu.add("Enviar E-mail");

    Intent intentEmail = new Intent(Intent.ACTION_SEND);
    intentEmail.setType("message/rtc822");
    intentEmail.putExtra(Intent.EXTRA_EMAIL, new String[] {"email-do-aluno@yahoo.com.br"});
    intentEmail.putExtra(Intent.EXTRA_SUBJECT, "Testando subject do email");
    intentEmail.putExtra(Intent.EXTRA_TEXT, "Testando corpo do email");
    email.setIntent(intentEmail);

meu codigo:

    final MenuItem mEnviarEmail = menu.add("Enviar Email");


        mEnviarEmail.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                /*
                Intent enviarEmailAluno = new Intent(Intent.ACTION_SEND);
                enviarEmailAluno.setType("message/rtc822");
                enviarEmailAluno.putExtra(Intent.EXTRA_EMAIL, new String[] {"henrique.ajs@gmail.com"});
                enviarEmailAluno.putExtra(Intent.EXTRA_SUBJECT, "Testando subject do email");
                enviarEmailAluno.putExtra(Intent.EXTRA_TEXT, "Testando corpo do email");
                mEnviarEmail.setIntent(enviarEmailAluno);
               // startActivity(enviarEmailAluno);
               */

                Intent intentEmail = new Intent(Intent.ACTION_SEND);
                intentEmail.setType("message/rtc822");
                intentEmail.putExtra(Intent.EXTRA_EMAIL, new String[] {"email-do-aluno@yahoo.com.br"});
                intentEmail.putExtra(Intent.EXTRA_SUBJECT, "Testando subject do email");
                intentEmail.putExtra(Intent.EXTRA_TEXT, "Testando corpo do email");
                mEnviarEmail.setIntent(intentEmail);
                startActivity(intentEmail);
                return false;
            }
        });

retorno do erro :

12-14 02:13:54.192  18244-18244/com.sugla.caelumcadastro E/InputEventReceiver﹕ Exception dispatching input event.
12-14 02:13:54.192  18244-18244/com.sugla.caelumcadastro E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback
12-14 02:13:54.193  18244-18244/com.sugla.caelumcadastro E/MessageQueue-JNI﹕ android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=message/rtc822 flg=0x1 (has clip) (has extras) }
            at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1781)
            at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501)
            at android.app.Activity.startActivityForResult(Activity.java:3745)
            at android.app.Activity.startActivityForResult(Activity.java:3706)
            at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:748)
            at android.app.Activity.startActivity(Activity.java:4016)
            at android.app.Activity.startActivity(Activity.java:3984)
            at com.sugla.caelumcadastro.ListaAlunosActivity$7.onMenuItemClick(ListaAlunosActivity.java:170)
            at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:147)
            at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904)
            at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894)
            at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167)
            at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1082)
            at android.widget.AdapterView.performItemClick(AdapterView.java:305)
            at android.widget.AbsListView.performItemClick(AbsListView.java:1146)
            at android.widget.AbsListView$PerformClick.run(AbsListView.java:3053)
            at android.widget.AbsListView.onTouchUp(AbsListView.java:3872)
            at android.widget.AbsListView.onTouchEvent(AbsListView.java:3637)
            at android.view.View.dispatchTouchEvent(View.java:8471)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2399)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2092)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
            at android.app.Dialog.dispatchTouchEvent(Dialog.java:765)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
            at android.view.View.dispatchPointerEvent(View.java:8666)
            at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
            at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
            at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
            at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807)
            at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5781)
            at and
12-14 02:13:54.194  18244-18244/com.sugla.caelumcadastro D/AndroidRuntime﹕ Shutting down VM
12-14 02:13:54.232  18244-18244/com.sugla.caelumcadastro E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.sugla.caelumcadastro, PID: 18244
    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=message/rtc822 flg=0x1 (has clip) (has extras) }
            at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1781)
            at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501)
            at android.app.Activity.startActivityForResult(Activity.java:3745)
            at android.app.Activity.startActivityForResult(Activity.java:3706)
            at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:748)
            at android.app.Activity.startActivity(Activity.java:4016)
            at android.app.Activity.startActivity(Activity.java:3984)
            at com.sugla.caelumcadastro.ListaAlunosActivity$7.onMenuItemClick(ListaAlunosActivity.java:170)
            at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:147)
            at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904)
            at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894)
            at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167)
            at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1082)
            at android.widget.AdapterView.performItemClick(AdapterView.java:305)
            at android.widget.AbsListView.performItemClick(AbsListView.java:1146)
            at android.widget.AbsListView$PerformClick.run(AbsListView.java:3053)
            at android.widget.AbsListView.onTouchUp(AbsListView.java:3872)
            at android.widget.AbsListView.onTouchEvent(AbsListView.java:3637)
            at android.view.View.dispatchTouchEvent(View.java:8471)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2399)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2092)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
            at android.app.Dialog.dispatchTouchEvent(Dialog.java:765)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
            at android.view.View.dispatchPointerEvent(View.java:8666)
            at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
            at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
            at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
            at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807)
            at android.view
4 respostas

Henrique, tudo bem ?

Faz um teste por gentileza, utiliza esse setType ;

intent.setType("message/rfc822");

Pois da forma que está enviando, ele procura no Android alguma activity que tenha esse protocolo e não está encontrando, o que faz o crash da app.

Fala se deu certo depois, por favor.

Abraços

Mesmo erro:

12-15 23:39:56.246 2022-2037/com.sugla.caelumcadastro W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa50230c0, error=EGL_SUCCESS 12-15 23:39:59.416 2022-2022/com.sugla.caelumcadastro E/InputEventReceiver﹕ Exception dispatching input event. 12-15 23:39:59.417 2022-2022/com.sugla.caelumcadastro E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback 12-15 23:39:59.444 2022-2022/com.sugla.caelumcadastro E/MessageQueue-JNI﹕ android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=message/rfc822 flg=0x1 (has clip) (has extras) } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1781) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501) at android.app.Activity.startActivityForResult(Activity.java:3745) at android.app.Activity.startActivityForResult(Activity.java:3706) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:748) at android.app.Activity.startActivity(Activity.java:4016) at android.app.Activity.startActivity(Activity.java:3984) at com.sugla.caelumcadastro.ListaAlunosActivity$7.onMenuItemClick(ListaAlunosActivity.java:170) at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:147) at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904) at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894) at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167) at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1082) at android.widget.AdapterView.performItemClick(AdapterView.java:305) at android.widget.AbsListView.performItemClick(AbsListView.java:1146) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3053) at android.widget.AbsListView.onTouchUp(AbsListView.java:3872) at android.widget.AbsListView.onTouchEvent(AbsListView.java:3637) at android.view.View.dispatchTouchEvent(View.java:8471) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2399) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2092) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369) at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719) at android.app.Dialog.dispatchTouchEvent(Dialog.java:765) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330) at android.view.View.dispatchPointerEvent(View.java:8666) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5781) at and

12-15 23:39:59.444 2022-2022/com.sugla.caelumcadastro D/AndroidRuntime﹕ Shutting down VM

beginning of crash 12-15 23:39:59.444 2022-2022/com.sugla.caelumcadastro E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.sugla.caelumcadastro, PID: 2022 android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=message/rfc822 flg=0x1 (has clip) (has extras) } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1781) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501) at android.app.Activity.startActivityForResult(Activity.java:3745) at android.app.Activity.startActivityForResult(Activity.java:3706) at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:748) at android.app.Activity.startActivity(Activity.java:4016) at android.app.Activity.startActivity(Activity.java:3984) at com.sugla.caelumcadastro.ListaAlunosActivity$7.onMenuItemClick(ListaAlunosActivity.java:170) at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:147) at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:904) at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:894) at com.android.internal.view.menu.MenuDialogHelper.onClick(MenuDialogHelper.java:167) at com.android.internal.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1082) at android.widget.AdapterView.performItemClick(AdapterView.java:305) at android.widget.AbsListView.performItemClick(AbsListView.java:1146) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3053) at android.widget.AbsListView.onTouchUp(AbsListView.java:3872) at android.widget.AbsListView.onTouchEvent(AbsListView.java:3637) at android.view.View.dispatchTouchEvent(View.java:8471) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2399) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2092) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106) at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369) at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719) at android.app.Dialog.dispatchTouchEvent(Dialog.java:765) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330) at android.view.View.dispatchPointerEvent(View.java:8666) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807) at android.view.

Henrique,

Pode colocar o código da sua classe, por gentileza.

Abraços

solução!

Achei isso aqui no Stack Overflow: http://stackoverflow.com/questions/14604349/activitynotfoundexception-while-sending-email-from-the-application

Traduzindo:

A mensagem de erro mostra:

ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=text/html flg=0x1 (has clip) (has extras) }

Isso significa que o sistema android não achou nenhuma activity responsável por enviar e-mails para lidar com a Intent criada por você. Tenha certa que você tem um aplicativo de e-mail instalado no seu dispositivo.

Use o código abaixo para enviar e-mails:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
try {
    startActivity(Intent.createChooser(i, "Send mail"));
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(MyActivity.this, "There are no email applications installed.", Toast.LENGTH_SHORT).show();
}