[JAVA] The basics of the process of making a call with an Android app

The basics of the process of making a call with an Android app

I had somehow implemented the process of making a call with the Android app, so I would like to describe it here again and take revenge on my own.

How to make a call from the Android app

How to use Intent's ACTION_CALL

By using ACTION_CALL of Intent, you can make a call with the number entered on the application side.

How to use Intent's ACTION_DIAL

By using Intent's ACTION_DIAL, you can open the dialer and phone app with the number entered on the app side.

Get permission for Dangerous permissions

The concept of permissions has changed since Android 6.0, and it has been divided into two types: permissions that require permissions for users and permissions that do not.

※review -Nomal permission: When installing the app, permission can be obtained based on the description in AndroidManifest.xml. -Dangerous permission: Permission can be obtained with the permission of the user. The authority can be revoked later by the user.

There are also Dangerous permissions related to the phone (permissions that belong to the permission group PHONE), so let's set to get the necessary permissions according to the purpose.

Basic code

   Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:012345678"));


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

Processing at the time of error

You may not be able to connect because you do not have permission to connect to the dialog / phone application. With this basic code, in the case of an exception, the phone will not be connected and there will be no notification on the screen, and the user will not know what is going on.

Therefore, let's add exception handling and set to notify the user of the exception content at the time of exception.

   Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:012345678"));

   //Exception handling from here
   }catch(e: SecurityException){
     Toast.makeText(context, "It's an error ...", Toast.LENGTH_SHORT).show()


・ Get each authority in advance. ・ Let's make a call using Intent. -Implement exception handling in case of an error. -Let's build measures for users who try to make outgoing operations on the app even though they do not have permission.

Recommended Posts

The basics of the process of making a call with an Android app
The story of making a reverse proxy with ProxyServlet
The story of making an electronic New Year's card app with Vue.js + Rails
A story packed with the basics of Spring Boot (solved)
About the basics of Android development
The story of the first Rails app refactored with a self-made helper
Understand the basics of Android Audio Record
I made a rock-paper-scissors app with android
The story of making a game launcher with automatic loading function [Java]
The basics of the App Store "automatic renewal subscription"
The story of tuning android apps with libGDX
The story of making an Android application that can adjust the sampling frequency of the accelerometer
I'm making an Android app and I'm stuck with errors and how to solve it
Practice making a simple chat app with Docker + Sinatra
Vibrate the wristband device with Bluetooth from the Android app
Test the contents of an Excel file with JUnit
I made a lock pattern using the volume key with the Android app. Fragment edition
The story of making dto, dao-like with java, sqlite
How to take a screenshot with the Android Studio emulator
Story of making a task management application with swing, java
Summary of initial work when creating an app with Rails
Check the operation of two roles with a chat application
How to make an app using Tensorflow with Android Studio
Explain the benefits of the State pattern with a movie rating
Find the number of days in a month with Kotlin
With the software I've been making for a long time ...
Docker monitoring-explaining the basics of basics-
Understand the basics of docker
The basics of Swift's TableView
Make an android app. (Day 5)
Is it an Android app?
I tried to take a look at the flow of Android development environment construction with Android Studio
Try to imitate the idea of a two-dimensional array with a one-dimensional array
A story of connecting to a CentOS 8 server with an old Ansible
The story of toString () starting with passing an array to System.out.println
A story about hitting the League Of Legends API with JAVA
Fall when animating a View containing an Android Recycler View with Transition
A story that struggled with the introduction of Web Apple Pay
[With sample code] Basics of Spring JDBC to learn with Blog app
The story of making a communication type Othello game using Scala.
[Illustration] Finding the sum of coins with a recursive function [Ruby]
[Android] Dynamically set the height of ListView with copy (for beginners)
The story of making it possible to build a project that was built by Maven with Ant
A story that I wanted to write a process equivalent to a while statement with the Stream API of Java8
Import device images with Android app
Create an app with Spring Boot 2
The basics of SpringBoot + MyBatis + MySQL
Creating a timer app with a muddy
Make an android app. (First day)
A memorandum of the FizzBuzz problem
Create an app with Spring Boot
Impressions of making BlackJack-cli with Ruby
I made a matching app (Android app)
[Android] I made a pedometer app.
A nice workaround when "having an instance of either of the two classes"
How to interact with a server that does not crash the app
Make a daily build of the TOPPERS kernel with Gitlab and Docker
Android application: Let's explain the mechanism of screen transition with simple code
Create a Spring Boot app development project with the cURL + tar command
Invoke the character string passed as an argument as a method with send
Let's express the result of analyzing Java bytecode with a class diagram