How to call with One Touch (without confirmation) on Android (Java)

No matter how much you find out how to make a call without confirmation on the net

Intent intent = new Intent(Intent.ACTION_DIAL, "tel:0123345678); ACTION_DIAL Intent intent = new Intent(Intent.ACTION_CALL, "tel:012345678"); It says OK just by setting ACTION_CALL like, but when I execute it, it falls for some reason (? _?)

Of course, in AbdroidManifest.xml, uses-permission android:name="android.permission.CALL_PHONE" I didn't forget to put it in, and when I was wondering why, It turns out that we have to give the app access to CALL_PHONE.

When I started the app, I had to display the permission dialog that gives access rights as shown below. CALL_PHONE is dangerous permission, so you have to get permission from each user (^^;)

public class MainActivity extends AppCompatActivity { static final int REQUEST_CODE = 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CALL_PHONE)==PackageManager.PERMISSION_DENIED) {
        ActivityCompat.requestPermissions(
                this, new String[] { Manifest.permission.CALL_PHONE }, REQUEST_CODE);
    }

@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    if (requestCode == REQUEST_CODE) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

// Dangerous permission request allowed } else { Toast toast = Toast.makeText (getApplicationContext (), "Cannot be used without adding phone function permissions", Toast.LENGTH_LONG); toast.show(); finish(); } } }

Recommended Posts

How to call with One Touch (without confirmation) on Android (Java)
Investigated how to call services with Watson SDK for Java
How to "hollow" View on Android
[Java] How to update Java on Windows
How to execute Postgresql copy command with column information on Java
Android: How to deal with "Could not determine java version from '10 .0.1'"
How to switch Java version with direnv in terminal on Mac
How to check Java installed on Mac
[Java] How to compare with equals method
[Android] How to deal with dark themes
How to detect microphone conflicts on Android
How to switch Java versions on Mac
How to save to multiple tables with one input
How to use Java framework with AWS Lambda! ??
How to use Java API with lambda expression
[Java] 4 steps to implement splash screen on Android
[Java] Memo on how to write the source
Let's touch on Java
[Android Studio] How to change TextView to any font [Java]
How to call AmazonSQSAsync
[Java 11] I tried to execute Java without compiling with javac
[Java] How to omit spring constructor injection with Lombok
How to deploy Java to AWS Lambda with Serverless Framework
[Java] How to encrypt with AES encryption with standard library
[Android Studio] [Java] How to fix the screen vertically
How to use Truth (assertion library for Java / Android)
As of April 2018 How to get Java 8 on Mac
[Java] How to execute tasks on a regular basis
How to run Java EE Tutial on github on Eclipse
[Java] How to start a new line with StringBuilder
Notes on how to use regular expressions in Java
How to develop an app with Jersey Java RESTful API on Alibaba Cloud ECS instance
How to reduce the load on the program even a little when combining characters with JAVA
How to take a screenshot with the Android Studio emulator
How to use OpenCV 4 on Android and view camera live view
How to use trained model of tensorflow2.0 with Kotlin / Java
How to handle exceptions coolly with Java 8 Stream or Optional
How to deploy a simple Java Servlet app on Heroku
Use Java included with Android Studio to build React Native
How to get values in real time with TextWatcher (Android)
How to call and use API in Java (Spring Boot)
How to install JDK 8 on Windows without using the installer
How to install java9 on elementaryOS Freya or Ubuntu 14.04 LTS
How to fix Android apps crashing with RenderThread mystery error
How to switch Java in the OpenJDK era on Mac
How to get started with JDBC using PostgresSQL on MacOS
[Java] How to use Map
How to lower java version
[Java] How to use Map
How to uninstall Java 8 (Mac)
Java to play with Function
Java --How to make JTable
How to use java Optional
How to deploy on heroku
How to minimize Java images
How to write java comments
[Java] How to use Optional ②
[Java] How to use removeAll ()
[Java] How to use string.format
How to use Java Map
Connect to DB with Java