"无活动来处理意图"同时,通过电子邮件发送数据 [英] "No Activity found to handle Intent" while emailing data

查看:211
本文介绍了"无活动来处理意图"同时,通过电子邮件发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这code试图邮件数据:

I am trying to mail data using this code:

email = (Button) findViewById(R.id.enail);
    email.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            Intent emailIntent = new Intent(
                    android.content.Intent.ACTION_SEND);
            emailIntent.setAction(Intent.ACTION_SEND);
            emailIntent.setType("message/rfc822");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    new String[] { "" });
            emailIntent.putExtra(android.content.Intent.EXTRA_CC, "");
            emailIntent.putExtra(android.content.Intent.EXTRA_BCC, "");
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                    "Playlist Details");
            emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(Detail));
            emailIntent.setType("text/html");
            startActivity(emailIntent);

        }
    });

但它引发以下错误:

But it throws the following error:

07-17 12:31:33.438: E/AndroidRuntime(498): FATAL EXCEPTION: main
07-17 12:31:33.438: E/AndroidRuntime(498): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND (has extras) }
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1408)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.app.Activity.startActivityForResult(Activity.java:2817)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.app.Activity.startActivity(Activity.java:2923)
07-17 12:31:33.438: E/AndroidRuntime(498):  at com.playlist.ViewPlayList$3.onClick(ViewPlayList.java:93)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.view.View.performClick(View.java:2408)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.view.View$PerformClick.run(View.java:8816)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.os.Handler.handleCallback(Handler.java:587)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.os.Handler.dispatchMessage(Handler.java:92)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.os.Looper.loop(Looper.java:123)
07-17 12:31:33.438: E/AndroidRuntime(498):  at android.app.ActivityThread.main(ActivityThread.java:4627)
07-17 12:31:33.438: E/AndroidRuntime(498):  at java.lang.reflect.Method.invokeNative(Native Method)
07-17 12:31:33.438: E/AndroidRuntime(498):  at java.lang.reflect.Method.invoke(Method.java:521)
07-17 12:31:33.438: E/AndroidRuntime(498):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-17 12:31:33.438: E/AndroidRuntime(498):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-17 12:31:33.438: E/AndroidRuntime(498):  at dalvik.system.NativeStart.main(Native Method)

请帮我。

推荐答案

我测试我的设备上,而code完美的作品。我testet这个code模拟器上,也和它坠毁。问题是,操作系统没有找到能够处理这个 ACTION_SEND 的任何活动。围绕这种code所有的时间用的try / catch ,因为你不能确定,如果存在,可以处理你的意图这样的活动。并尝试至少安装一个应用程序,可以处理 ACTION_SEND ,然后再试一次,看看它是否适合你。

I tested this on my device, and the code works perfectly. And I testet this code on an emulator, too, and it crashed. The problem is that the OS didn't find any activities which can handle this ACTION_SEND. Surround this kind of code all the time with a try/catch, since you can not be sure if there exists such an activity that can handle your intent. And try to install at least one app that can handle the ACTION_SEND, then try again, and see if it works for you.

这篇关于"无活动来处理意图"同时,通过电子邮件发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆