This video tutorial will show you how to Input Phone number or *# code and pass it to Dialer Intent using Java language and Android Studio.
>>Watch For Java
Video
MainActivity.kt
>>Watch For Java
Video
Step 1: Create a new Project or open new project
Step 2: Code
activity_main.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout 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" android:gravity="center" android:orientation="vertical" tools:context=".MainActivity"><!--Edit text to input number/code--><EditTextandroid:id="@+id/numberEt"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/bg_edittext"android:hint="Enter Number/Code..."android:inputType="phone"android:minWidth="200dp"android:padding="10dp"/><!--Button to dial number/code--><Buttonandroid:id="@+id/dialBtn"style="@style/Base.Widget.AppCompat.Button.Colored"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="10dp"android:drawableStart="@drawable/ic_call_white"android:drawableLeft="@drawable/ic_call_white"android:drawablePadding="10dp"android:text="Dial"android:minWidth="120dp"android:textSize="20sp"/></LinearLayout>
package com.blogspot.atifsoftwares.dialerintent_kotlinimport android.content.Intentimport android.net.Uriimport android.support.v7.app.AppCompatActivityimport android.os.Bundleimport kotlinx.android.synthetic.main.activity_main.*class MainActivity : AppCompatActivity() {internal var number:String?=""override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)//button click handledialBtn.setOnClickListener {//get input from edit textnumber = numberEt.text.toString().trim()//Dialer intentval intent = Intent(Intent.ACTION_DIAL , Uri.parse("tel:" + Uri.encode(number)))startActivity(intent)}}}
0 Response to "Dialer Intent - Android Studio - Kotlin"