Activity man xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/btn"
android:layout_width="warp_content"
android:layout_height="warp_content"
android:layout_centerInParent="true"
android:tex="Contact via whatsapp"/>
</RelativeLayout>
Manactivity.java
package com.example.whatsspbutton;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn=findViewById(R.id.btn);
btn.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
String wpur="https;//wa.me+916367094588?tex=Hi,Is any one one Available?";
Intent intent=new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(wpur));
startActivity(intent);)
}
}