Posts

Showing posts from June, 2023

Call Intent - Android Studio - Kotlin

Image
Open Call Intent with Phone Number using Android Studio and Kotlin We will use intent to open the dialer with the phone number the user entered. In this example, we will input a phone number using an input field, i.e., EditText, and open that phone number in the dialer screen by clicking the button. >> Check for Java >> Check for Kotlin >> Check for Compose Code Snippet: val intent = Intent(Intent.ACTION_VIEW, Uri.parse( "tel:${Uri.encode(phone)}" )) startActivity(intent) Full Example: 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= ...

Call Intent - Android Studio - Java

Image
Open Call Intent with Phone Number using Android Studio and Java We will use intent to open the dialer with the phone number the user entered. In this example, we will input a phone number using an input field, i.e., EditText, and open that phone number in the dialer screen by clicking the button. >> Check for Java >> Check for Kotlin >> Check for Compose Code Snippet: Intent intent = new Intent ( Intent . ACTION_VIEW , Uri . parse ( "tel:" + Uri . encode ( phone ))); startActivity ( intent ); Full Example: 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" ...