How to open Gmail Compose when a button is clicked in Android App?

后端 未结 11 1024
别跟我提以往
别跟我提以往 2020-12-01 06:25

I am trying to open up Gmail Compose screen when a button is clicked in my Android App. Do I need some API key for this from Google? or what do I need to do in my button onC

11条回答
  •  猫巷女王i
    2020-12-01 07:21

    You can use Simple Intent.ACTION_SEND intent set Intent.EXTRA_EMAIL for array of emails set Intent.EXTRA_SUBJECT for subject line in email composer Explore more EXTRA options available here -> https://developer.android.com/guide/components/intents-common#Email

    Here's a quick code snippet

    Intent intent = new Intent(Intent.ACTION_SEND);
                    intent.setType("*/*");
                    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"test@gmail.com"});
                    intent.putExtra(Intent.EXTRA_SUBJECT, "Feedback");
                    if (intent.resolveActivity(ctx.getPackageManager()) != null) {
                        startActivity(intent);
                    }
    

提交回复
热议问题