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
Intent intent = new Intent(Intent.ACTION_SEND).setType("text/plain")
.putExtra(Intent.EXTRA_EMAIL, new String[]{emails});
List matches = activity.getPackageManager().queryIntentActivities(intent, 0);
ResolveInfo best = null;
for (ResolveInfo info : matches) {
if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail")) {
best = info;
}
}
if (best != null) {
intent.setClassName(best.activityInfo.packageName,best.activityInfo.name);
}
activity.startActivity(intent);