打开gmail消息意图

时间:2011-07-25 14:24:12

标签: android android-intent gmail

我使用此意图打开Gmail邮件,但我想我需要添加一些关于ID的额外信息,我不知道额外的密钥。

Intent gmintent = new Intent(Intent.ACTION_VIEW); 
gmintent.setClassName("com.google.android.gm", "com.google.android.gm.HtmlConversationActivity"); 
gmintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(gmintent);

到ZZZZZZZover9000

public class MessageListClickListner implements OnItemClickListener{

    private Context context;
    private List<Map<String, String>> groupOfChilds;

    public MessageListClickListner(Context context, List<Map<String, String>> groupOfChilds) {
        super();
        this.context = context;
        this.groupOfChilds = groupOfChilds;
    }

    @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
        if("sms".equalsIgnoreCase(groupOfChilds.get(position).get("TYPE"))){
            Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("content://mms-sms/conversations/"+groupOfChilds.get(position).get("ID")));
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        }else{
            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.setType("text/plain");
            sendIntent.putExtra(Intent.EXTRA_SUBJECT,"Email subject");
            sendIntent.putExtra(Intent.EXTRA_TEXT, "Body of Email");
            sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(Intent.createChooser(sendIntent, "Email:"));

/*          Intent gmintent = new Intent(Intent.ACTION_VIEW); 
//          gmintent.putExtra("id", groupOfChilds.get(position).get("ID"));
            gmintent.setClassName("com.google.android.gm", "com.google.android.gm.HtmlConversationActivity"); 
            gmintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(gmintent);*/
        }
    }
}

3 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

试试这个:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_SUBJECT,"Email subject");
sendIntent.putExtra(Intent.EXTRA_TEXT, "Body of Email");
startActivity(Intent.createChooser(sendIntent, "Email:"));

用户可以选择使用哪个电子邮件客户端。

答案 2 :(得分:1)

试试这个:

gmintent.putExtra("key", "value");