ActivityNotFoundException而从应用程序发送电子邮件 [英] ActivityNotFoundException while sending email from the application

查看:137
本文介绍了ActivityNotFoundException而从应用程序发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了code中,我允许用户的通过电子邮件发送订单的为供应商[ShopOwner]伴随着他们的个人和车项目的细节,但在这里,我正在一个

I have written a code in which I am allowing user to send order via email to vendor [ShopOwner] along with their personal and cart item details, but here I am getting an

错误:不幸的是应用程序已停止

logcat的:

01-30 17:56:14.605: E/AndroidRuntime(951): FATAL EXCEPTION: main
01-30 17:56:14.605: E/AndroidRuntime(951): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.SEND typ=text/html flg=0x1 (has clip) (has extras) }
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.app.Activity.startActivityForResult(Activity.java:3370)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.app.Activity.startActivityForResult(Activity.java:3331)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.app.Activity.startActivity(Activity.java:3566)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.app.Activity.startActivity(Activity.java:3534)
01-30 17:56:14.605: E/AndroidRuntime(951):  at com.version.bajrang.january.menu.ArrowsActivity$1.onClick(ArrowsActivity.java:105)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.view.View.performClick(View.java:4202)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.view.View$PerformClick.run(View.java:17340)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.os.Handler.handleCallback(Handler.java:725)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.os.Handler.dispatchMessage(Handler.java:92)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.os.Looper.loop(Looper.java:137)
01-30 17:56:14.605: E/AndroidRuntime(951):  at android.app.ActivityThread.main(ActivityThread.java:5039)
01-30 17:56:14.605: E/AndroidRuntime(951):  at java.lang.reflect.Method.invokeNative(Native Method)
01-30 17:56:14.605: E/AndroidRuntime(951):  at java.lang.reflect.Method.invoke(Method.java:511)
01-30 17:56:14.605: E/AndroidRuntime(951):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-30 17:56:14.605: E/AndroidRuntime(951):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-30 17:56:14.605: E/AndroidRuntime(951):  at dalvik.system.NativeStart.main(Native Method)

code:

Intent messageIntent = new Intent(android.content.Intent.ACTION_SEND);
String aEmailList[] = { "rakesh@rocketmail.com" };   
messageIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
messageIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
messageIntent.setType("text/html");
messageIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body.toString()));
startActivity(messageIntent);

最后与SahilMahajanMj的帮助,我已经使用这个code变化不大:

Finally with the Help of SahilMahajanMj, I have used this code with little change:

 Intent i = new Intent(Intent.ACTION_SEND);
 i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"rakesh@rocketmail.com"});
 i.putExtra(Intent.EXTRA_SUBJECT, subject);
 i.setType("message/rfc822");
 i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(body.toString()));

try {
    startActivity(Intent.createChooser(i, "Send email via :"));
    Toast.makeText(ArrowsActivity.this, "Email Sent.", Toast.LENGTH_SHORT).show();
} catch (android.content.ActivityNotFoundException ex) {
    Toast.makeText(ArrowsActivity.this, "There are no email applications installed.", Toast.LENGTH_SHORT).show();
}

ViewCartActivity.java

public void onClick(View v) {
    // TODO Auto-generated method stub

        Intent mViewCartIntent = new Intent(ViewCartActivity.this, com.version.bajrang.january.menu.ArrowsActivity.class);
        mViewCartIntent.putExtra("name", myTextVeiwGrandTotal.getText().toString());
        startActivity(mViewCartIntent);

            }
        });

ArrowsActivity.java:

TextView txtName = (TextView) findViewById(R.id.total);
Intent i = getIntent();
String name = i.getStringExtra("name");
txtName.setText(name);

我使用上述code,以获得产品在购物车总数量,我能够获得并显示为好,但在车中的商品在这里总人数我也想表现出像车标签:

I am using above code to get total number of products in cart and i am able to get and show as well, but here total number of items in cart i also want to show on cart tab like:

<一个href="https://play.google.com/store/apps/details?id=com.queppelin.tastykhana">https://play.google.com/store/apps/details?id=com.queppelin.tastykhana

他们在红色显示2 ...

they have shown 2 in red...

推荐答案

该错误消息显示:

ActivityNotFoundException:无活动来处理意向{   ACT = android.intent.action.SEND典型值= text / html的FLG =为0x1(有夹)(有   演员)}

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

这意味着Android系统的犯规中的任何邮件发送活动,以处理所创建的意图。请确保你已经安装在设备中的电子邮件应用程序。

It means that the android system doesnt found any email sending activity to handle the intent created by you. Make sure you have email application installed in your device.

也可以使用下面的code发送电子邮件,

Also use the following code to send email,

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

这篇关于ActivityNotFoundException而从应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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