2013-02-05 46 views
0

更新:电子邮件意向问题。无法选择电子邮件选项

管理对gmail的加载进行排序。

现在我无法在意图加载时设置gmail的'收件人','主题'和'消息'字段。

截图显示我的电子邮件布局:

enter image description here

截图显示加载gmail的意图。但没有从传递的细节设置字段。

enter image description here

代码:

@Override 
public void onClick(View sendEmailClick) { 


    Intent sendEmailIntent = new Intent(Intent.ACTION_SEND); 
    sendEmailIntent.setType("plain/text"); 
     sendEmailIntent.putExtra(Intent.EXTRA_EMAIL, emailAdd); 
     sendEmailIntent.putExtra(Intent.EXTRA_SUBJECT, emailSub); 
     sendEmailIntent.putExtra(Intent.EXTRA_TEXT, emailMess); 
     startActivity(Intent.createChooser(sendEmailIntent, "Send email")); 

     //startActivity(Intent.createChooser(sendEmailIntent, "Send email...")); 
} 
+0

使用intent.setType(“text/plain”); – dymmeh

回答

1

如果默认的电子邮件客户端不会有一个帐户,它不应该注册本身Intent.ACTION_SEND。确保你有一个帐户添加到应用程序,并尝试再次发送您的电子邮件。如上所述,使用"text/plain"作为类型。

From what I can find on short notice:

<activity 
      android:name=".activity.MessageCompose" 
      android:label="@string/compose_title" 
      android:enabled="false" 
      android:theme="@android:style/Theme.Holo.Light" 
      > 

撰写活动是不是默认启用的,一旦你添加的帐户应该启用。

+0

非常感谢您的回复。我已经添加了我的Gmail帐户,现在当我点击发送按钮时,onclick方法开始了这个意图。我现在唯一的问题是我是否似乎无法通过我传递的意向详细信息设置Gmail'To''主题'和'消息'字段?我会更新我的问题以表明这一点。 – user1352057

0

您可以发送电子邮件也没有外部应用程序:

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 

String[] recipients = new String[]{"[email protected]", "",}; 

emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients); 

emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Test"); 

emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is email's message"); 

emailIntent.setType("text/plain"); 

startActivity(Intent.createChooser(emailIntent, "Send mail...")); 

finish(); 
+0

感谢您的回复。你的意思是,我不需要选择一个电子邮件应用程序来发送我的电子邮件?我已经尝试过你的startActivity,并且遇到同样的问题。我不使用字符串数组是否需要这种方法工作?我只是用我的edittext值设置'.EXTRA_EMAIL'。 – user1352057

+0

是的,你不需要申请发送申请。你可以声明你的edittext并获得文本'String s = et.getText()。toString();'。现在你可以......“EXTRA_TEXT,s);' – TN888

0
try { 
    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{recipient}); 
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); 
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message); 
    emailIntent.setType("plain/text"); 
    startActivity(Intent.createChooser(emailIntent, "Send email")); 
} catch (ActivityNotFoundException e) { 
    Log.i("app name", "Unable to send email"); 
} 
0

设法拿到了第二部分TI这个整理。您需要将其作为字符串数组传递给Gmail,而不仅仅是一个纯字符串。希望这将在未来拯救别人的问题!