I have a class that makes a call to an emergency number. I get to the "call" app with the phone number already passed in, but i still have to press the Call Button to start the call.
Is there a possibility where i don't actively have to press the call button but it does it automatically?
Emergency numbers always require that the user presses a button explicitly. This is a security feature.
See docu for ACTION_CALL
As henry has mentioned in his answer, its only possible call emmergency number using ACTION_DIAL. Howerver you can call anyother number directly using this intent.
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "ur phoneNumber here"));
startActivity(intent);
Dont Forget to Add this Permission to the Manifest :
<uses-permission android:name="android.permission.CALL_PHONE" />
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + bundle.getString("mobilePhone")));
context.startActivity(intent);
Permission required is
<uses-permission android:name="android.permission.CALL_PHONE" />
Related
I tried to make a call when I click on Android Mobile field with this code
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+contactNo));
startActivity(callIntent);
And added these in AndroidManifest.xml
<uses-permission android:name="packagename.permission.C2D_MESSAGE"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
And finally I am getting **java.lang.SecurityException** exception.
Why it Happens? and What is the Correct Procedure to Make a Call when click on Contact field?
use Intent.ACTION_DIAL instead of Intent.ACTION_CALL
And action_dial does not need permission, and it will show dialed phone number to user on dialer and then it will be users wish to place a call or not. This will be better approach to give user a control of what they wants to do.
hope that will help you
In order to use Intent.ACTION_CALL you have to add a permission to your manifest.
Add this permission to your manifest and it should be ok
<uses-permission android:name="android.permission.CALL_PHONE"/>
I'm trying to write an app that, among other things, calls people. To do this, I use the following code:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + number));
callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(callIntent);
The problem is: When I run it, it shows me a dialog and I need to choose with which app I want to make the call (Skype/Viber/Dialer/etc.). How can I make the call immediately using the standard dialer (without the dialog showing up)?
The difference between Intent.ACTION_DIAL and Intent.ACTION_CALL is that the first one allows the user to explicitly initiate the call showing the dialer UI. When using ACTION_CALL, a pop-up will open and let you choose which dialer to use.
Also, add permission on your manifest:
<uses-permission android:name="android.permission.CALL_PHONE" />
i have been trying this prblemstatement. when triggered with a bluetooth file transfer android phone has to make an automatic phone call to a given number .Can any help with the coding in android for this purpose.
I need code to start phone call from bluetooth like when i send data from it to phone then the phone should automatically call apredefined number.
public void call() {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+phone));
startActivity(callIntent);
}
is the function you need to call as soon as the transfer is triggered.
String phone = "tel:" + "03242342342" ;
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(phone));
startActivity(intent);
you need to add permission for that.
<uses-permission android:name="android.permission.CALL_PHONE" />
or better approach to use
Intent.ACTION_DIAL
as intent filter in order to avoid permission, ACTION_DIAL will choose appropriate app for phone calling.
I have the folowing code and im starting it from a dialog fragment button:
uri = "tel:"+ServerDialogCallUs.this.contents.getString("phone_number");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
Instead of making a normal phone call this code starts a skype call. How can I give the user the option to chose between the normal call and a skype call.
Thanks
actually, i was missing the permission:
<uses-permission android:name="android.permission.CALL_PHONE" />
after adding this permission to the manifest I can chose between a normal and a skype call.
Thanks
Try to call setPackage() method, works fine:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setPackage("com.android.phone");
intent.setData(Uri.parse("tel:" + number));
startActitivy(intent);
Had the same issue and tried some answers:
Intent.ACTION_CALL will call, which needs probably the right permission, BUT using Intent.ACTION_DIAL and use an Intent Chooser, I got the right behaviour.
Regarding USSD like "*123*03#" which pops up also as question in this context, where android says, it cannot handle the intent
2.1. Uri.encode("#") is not the solution, it just adds a "23" to the phone numer
2.2. Skype handles the number wrong, it adds the country-code like +001. So Skype does not handle USSDs correctly. But it seems, I have no chance, to exclude this.
So, I did:
final Intent intent = new Intent();
intent.setAction(Intent.ACTION_DIAL);
intent.setData(Uri.fromParts("tel", "123456", null));
startActivity(Intent.createChooser(intent, ""), REQUEST_CODE));
From my point of view
intent.setPackage("com.android.phone");
is device dependent or at least does not leave "phone" included on my device.
That's because
There is only skype installed as a phone call handler or
You associated skype as default handler for phone calls.
In the latter case, go to settings, apps, skype, and remove that association on the bottom of the app details screen.
Your phone probably has Skype as the default app to handle the Intent.ACTION_CALL
Try the following code:
uri = "tel:"+ServerDialogCallUs.this.contents.getString("phone_number");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
startActivity(Intent.createChooser(intent, "Call Using..."));
I start a call intent like this :
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+numberToCall));
startActivity(callIntent);
but instead of directly calling that number I see the calling screen with the number prefilled and I have to press the call button in order to call. Is it possible to call directly without having to press the call button?
Thanks
Add this to your manifest. It will allow you to call a phone without prompt
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
CALL_PHONE: Allows an application to initiate a phone call without going through the Dialer user interface for the user to confirm the call being placed.
Which can be found here:
http://developer.android.com/reference/android/Manifest.permission.html
You can dial number by using the CALL_PHONE permission. For other, privileged, numbers use the CALL_PRIVILEGED permissison.