How to open and send email using the native client directly from your Android App? – Source Code

In this short video, it shows the steps to create and Email client opening App. In this simple App, it just has one button. Clicking on that button it opens up the in-built default (native) email client of the phone.

The use case of this concept will be to add a contact button in your business App where when a user clicks on that contact button, it opens up the email client on their phone with your business email ID already fed in.

We hope you like this video. For any query, suggestions or appreciations we will be glad to hear from you at: programmerworld1990@gmail.com


Source Code:

package com.example.myemailclientopeningapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void EmailButton(View view){
startActivity(new Intent(Intent.ACTION_SENDTO, Uri.parse(“mailto:abc@gmail.com”)));
}
}

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
package=”com.example.myemailclientopeningapp”>

<application
android:allowBackup=”true”
android:icon=”@mipmap/ic_launcher”
android:label=”@string/app_name”
android:roundIcon=”@mipmap/ic_launcher_round”
android:supportsRtl=”true”
android:theme=”@style/AppTheme”>
<activity android:name=”.MainActivity”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />

<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application>

</manifest>

Leave a Reply

%d bloggers like this: