Step 1 main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/feedback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Feedback"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Step 2 Main.xml
package in.xtremeworkplace.feedback;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button feedback;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
feedback =(Button) findViewById(R.id.feedback);
feedback.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
String UriText = "mailto:" + Uri.encode("rohitsharma.creator@gmail.com") +"?subject="+
Uri.encode("Feedback") +"$body="+ Uri.encode("");
Uri uri = Uri.parse(UriText);
intent.setData(uri);
startActivity(Intent.createChooser(intent,"send email"));
}
});
}
}
GITHUB : https://github.com/LearncodeWithRk/Feedback-in-Android-Studio
0 Comments