Android Call , Message, WhatsApp Intent Button

 Xml file


<Button
android:id="@+id/call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Call"
android:onClick="call"/>

<Button
android:id="@+id/msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:onClick="sendmsg" />


<Button
android:id="@+id/wabtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WhatsApp"
android:onClick="wabtn"/>


Activity Kt file

fun call(view: View) {
val dialIntent = Intent(Intent.ACTION_DIAL)
dialIntent.data = Uri.parse("tel:" + "+88018123456789")
startActivity(dialIntent)
}
fun sendmsg(view: View) {
val intent = Intent(Intent.ACTION_SENDTO)
intent.data = Uri.parse("smsto:+88018123456789")
startActivity(intent)
}

fun wabtn(view: View) {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("whatsapp://send?phone=+88018123456789")
startActivity(intent)
}



AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />





Comments