when I use this code, first comes the dial pad screen with this number.
Intent dialintnt = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:911"));
startActivityForResult(dialintnt, CALLING);
I don't want that screen. I want that when I click button directly calling that number.
So how can I call a number onclick
?
See the answer
You will need add
CALL_PHONE
andCALL_PRIVILEGED
permissions to manifest file.Then the number can be called using:
Just change
ACTION_DIAL
toACTION_CALL
.Like this:
It's not possible. This is for user protection.
Try this:
Number has to be proper formatted as if you try with country code it will take you default dailer. i tested it on my app when i am using number as 198 call is happening directly and when i am using 9999999999 this will invoke the dailer so that user can correct the number by adding country code.
It's been a long time. But may help someone else. If you want to call directly, you should use requestPermissions method.
1. Add this line to your manifest file:
2. Define a class variable in the activity class:
3. Add these lines to the onCreate method of the activity:
4. And for making a call immediately after clicking on Allow button, override onRequestPermissionsResult method:
When a user give the permission, next time there will be no dialogue box and call will be make directly.