ActivityNotFoundException例外Gmail

ActivityNotFoundException例外Gmail

本文介绍了在果冻豆ActivityNotFoundException例外Gmail的作曲家的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本类适用于ICS很好,但失败 ActivityNotFoundException 的果冻豆。难道你们知道为什么吗?谢谢你。

 公共类EmailSender {    公共静态意图getSendEmailIntent(上下文的背景下,字符串电子邮件,
                                            主题字符串,字符串的身体,文件的文件名,字符串chooserTitle){        最终意图emailIntent =新意图(
                android.content.Intent.ACTION_SEND);        //明确只使用Gmail发送
        emailIntent.setClassName(com.google.android.gm,com.google.android.gm.ComposeActivityGmail);        emailIntent.setType(纯/文);        //添加收件人
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                新的String [] {电子邮件});        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,学科);        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,体);        //通过指定我们的定制的ContentProvider参考添加附件
        //和感兴趣的特定文件
        emailIntent.putExtra(
                Intent.EXTRA_STREAM,
                Uri.fromFile(文件名));        返回emailIntent;
    }
}

在果冻豆我得到异常:

Full trace in case of need:

解决方案

I'd advise against using an intent to directly open the gmail compose activity. Using such a strict intent means that the user needs to have gmail installed to use your app. Not everybody uses gmail for their mail client.. Additionally, by hardcoding class names you leave yourself open to instances where the class name changes can result in your activity breaking (which is the cause of your current problem)

I decompiled the gmail 4.2 application and found that the ComposeActivity class name and path has changed.. it is now com.android.mail.compose.ComposeActivity

You should use a general email intent that allows the user to use the email application of their choosing

这篇关于在果冻豆ActivityNotFoundException例外Gmail的作曲家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 07:15