Call without pressing the call button - android

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.

Related

I want to call on mobile number but don't want user to show the dial number,to hide the privacy of dialled number

I am developing an app for a cab and have to implement the call facility.I am done with this calling feature but it is showing the dialed number in dialer, but I am in need to hide the dial number from the dialer.we are doing this just to make female passenger safe and comfortable while having the ride and after the ride.
While calling Intent, Use Intent.ACTION_CALL. It will directly call at particular number without showing dialer to user.
Use Intent.ACTION_CALL it will directly call
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:100"));
startActivity(intent);

Android: make immediate calls

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" />

Make a phone call without pressing the call button

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" />

Programmatically enter secret code like *#*#4636#*#* on Android

On many Android devices you can get into a secret settings menu from Phone app by typing in
*#*#4636#*#*
http://technology-headlines.com/2010/09/17/4636-android-secret-codes/
There are also some other codes.
Is it also possible to open this stuff programmatically?
I've tried this:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:*#*#4636#*#*"));
startActivity(intent);
But it just tries to initiate a phone call and of course fails, hangs up and closes the Phone app.
EDIT: The phone *#*#4636#*#* gets saved to my Contact list as "Unknown" but the call just fails. In fact, the secret code only works when you type manually on buttons in Phone app without pressing Call in the end. Is it probably just a hidden feature of Phone app which has nothing to do with calling?
If so, one could open the Phone app programmatically and simulate typing on the buttons.
According to this post
Programmatically press a button in another appplication's activity
this should NOT be possible because if any app on non-rooted phone could just start other apps and press something there, it could take over control of the whole device and do bad things.
Here are some more details but I guess the post is a bit old and even if it worked it may have been changed in current Android versions:
http://mylifewithandroid.blogspot.de/2009/01/generating-keypresses-programmatically.html
So, no easier way to enter secret code?
Is it also possible to open this stuff programmatically?
Yes:
Intent in = new Intent(Intent.ACTION_MAIN);
in.setClassName("com.android.settings", "com.android.settings.TestingSettings");
startActivity(in);
You just need to watch logcat output to learn what this magic combination actually opens:
I/ActivityManager(31362): START {act=android.intent.action.MAIN
flg=0x10000000 cmp=com.android.settings/.TestingSettings} from pid
4257
Secret codes exist and work independent of the dialer application. The dialer application just provides a handy interface for these codes. It recognizes the special string and then calls a special intent to invoke the action. You shouldn't use the dialer to call these dialogs. Instead you can call the secret codes directly yourself like the dialer does internally:
Invoking built in secret codes:
What the dialer really does when you enter the code is extracting the number between *#*# and #*#* and then broadcasting the following intent:
sendBroadcast(new Intent("android.provider.Telephony.SECRET_CODE", Uri.parse("android_secret_code://4636")));
Register your own secret codes (if you like):
You can even register your own secret code actions using:
<action android:name="android.provider.Telephony.SECRET_CODE" />
<data android:scheme="android_secret_code" android:host="4636" />
Source: http://android.amberfog.com/?p=422
Edit: Fixed a bug in the original code (see comment)
try this
String ussdCode = "*" +Uri.encode ("#")+"*"+Uri.encode ("#")+ "4636" + Uri.encode ("#")+"*"+Uri.encode ("#")+"*";
startActivity (new Intent ("android.intent.action.CALL", Uri.parse ("tel:" + ussdCode)));
finally you must encode '#' using Uri.encode()
ACTION_DIAL sends the user to the dialer with the given code (it does not call). So that would be :
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:*#*#4636#*#*"));
startActivity(intent);
It would appear that codes are to be dialed, rather than to be called
looking for this
Intent intent = new Intent("android.intent.action.MAIN");
intent.setClassName("com.android.settings", "com.android.settings.Settings$TestingSettingsActivity");
startActivity(intent);
There are different activities for different phone, we can jump to the activity through typing in ##4636##.
And use
adb shell dumsys activity activities
to find the realActivity package and name.
e.g: Xiaomi 8
Intent intent = new Intent("android.intent.action.MAIN");
intent.setClassName("com.android.settings", "com.android.settings.Settings$TestingSettingsActivity");
startActivity(intent);

How to make key presses on dial pad, programmatically?

I have to write a program to call, using call card. My questions are:
1. How to know phone is ringing and received at the receiver's end.(e.g. At service provider like 1800).
2. After received I want to make key presses for desired number on dial pad in program.
(or if any way to make key press events and append call to first one(e.g.1800), please tell!).
if any idea to append call to SP's number, please Help!
to make call programmatically:
Intent call = new Intent(Intent.ACTION_CALL);
call.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
call.setData(Uri.parse("tel:" + number));
startActivity(call);
add this permission to your manifest file:
<uses-permission android:name="android.permission.CALL_PHONE" />
After received I want to make key presses for desired number on dial pad in program. (or if any way to make key press events and append call to first one(e.g.1800), please tell!).
This is not possible, sorry.

Categories

Resources