searched for a solution but haven't found anything even similar.
When dialing a number from the Android Phone application, based on a prefix predefined earlier, I intercept a call. Afterwards I place another call which number is some access number + 2 sec pause + the number intercepted + #-sign.
My question is - is there any possibility (any ACTION_CALL intent extra or something) that this intercepted and not the access number is shown in the Android Phone application?
Example:
Access Number: 999999
Prefix: 011
Number: 011552657659
Thus, newly placed call is 999999,011552657659#.
Result: the Phone application shows 999999 and other digits are dialed tonally, while I want a user to see something 011552657659 instead.
My code is:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:999999,011552657659#");
context.startActivity(intent);
Thank you in advance!
Related
I've been working on an android app concept in which the app has to auto-dial some special USSD codes in order to initiate certain telco services of interest to the user when the user initiates the service via a shortcut in the app.
The trouble I'm finding is that when the app tries to auto-dial such short codes or USSD numbers, the phone's OS (or is it the Call Intent), doesn't auto-dial, but instead presents the user with the code/number in the dial-pad and so the user has to manually initiate the call - which sort of defeats my intention of allowing users to initiate the services with just one click - the shortcut.
Currently, this is how I'm initiating these calls:
intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + number.trim()));
try {
activity.startActivity(intent);
} catch (Exception e) {
Log.d(Tag, e.getMessage());
}
Interestingly, a number such as +256772777000 will auto-dial, launching the user into the call automatically, but a number/code such as 911, *112#, *1*23#, etc won't.
So, what do I need to do differently, or is this not possible at all?
UPDATE
Actually, looking at another app in which I was autodialling user-specified numbers, the problem with the above code trying to auto-dial ussd codes was that instead of using intent.ACTION_CALL, I was using intent.ACTION_DIAL - which definitely just prompts the user with the number to call, without directly calling it. When I fixed that, the app now works as expected. See answer below...
Code samples are most welcome.
Actually, despite what some people were claiming about Android preventing such a feature. When I looked at the code in one of my older apps which auto-dials user-specified numbers, I found the solution to be:
intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number.trim()));
try {
activity.startActivity(intent);
} catch (Exception e) {
Log.d(Tag, e.getMessage());
}
This works as expected - USSD codes get auto-dialled when above code runs. The only important thing to note when using this approach, being that you have to add the following permissions to your manifest:
<uses-permission android:name="android.permission.CALL_PHONE" />
So, as indicated in the update to my question, the problem with my original approach was using intent.ACTION_DIAL instead of intent.ACTION_CALL.
Wrote a little program, when you click on the number of calls, and all would be well in this tale, but tested it on another phone, and when you just departed from the program, but then I remembered that he had dual sim.Tak how to put that to standard sim card when you run the program was 1 or 2? or given a choice, what would the user chose how the sim card to call him?
Tried to use getDeviceId (), writes that "Non-static metod ...".
That part of the code that is used to make a call:
final Intent calling1 = new Intent(Intent.ACTION_CALL);
call1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
calling1.setData(Uri.parse("tel:5555"));
startActivity(calling1);
}
});
On android 4.2.1 by pressing all comes with the application, writes an error, how to fix it too, do not tell?
Do this:
Intent i = new Intent(Intent.ACTION_CALL)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// set active SIM
i.putExtra("simSlot", SimIndex); // <-------------------
i.setData(Uri.parse("tel:" + phone));
startActivity(i);
Where SimIndex is 0 or 1 for first & second SIM cards, respectively.
On some devices the SIM setting line will be:
// set active SIM
i.putExtra("com.android.phone.extra.slot", SimIndex)
You would probably want to create a fallthrough mechanism that start with the
prior way and, if fails, attempts the latter.
Hope it helps.
I am trying to implement calling facility from my app. When some condition is true, I am hiding my caller id by adding #31# before my number. Although if #31# is not added, call is made perfectly allright but when #31# is added, blank screen pops up, as if the Phone app is loading, and my application screen comes back. My code snippet is this
String ph = "123456789";
String phNumber;
if (hideCallerId) {
phNumber = "#31#" + ph;
}
else {
phNumber = ph;
}
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:"+phNumber));
startActivity(intent);
Case 1: when phNumber is 123456789, then call is made without problem.
Case 2: when phNumber is #31#123456789, then blank screen pops up and user comes back to my application screen.
Although when I am dialing from my device using #31#123456789, call is successfully made.
What I am missing out. Can anybody help me out.
Links didn't helped me Link1.
Thanks in advance.
This isn't really an answer but my rep isn't high enough for a comment. Is there any chance you have phnumber declared as an int or anything? Maybe the #'s are messing it up?
If that doesn't work have you tried using ACTION_DIAL? the android developer site has more info on the differences between them here. Hope it helps.
You simply have to encode the phone number.
String phonenumber = "03012345,1234,#31#,98765"; // , = pauses
encodedPhonenumber = URLEncoder.encode(phonenumber, "UTF-8");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + encodedPhonenumber)));
You may want to have a look at this one. Not able to make a call when #31# is added
You need to encode the '#' because it behaves like a dial command, then if you set your action call intent data with a number starting with '#', it will instead call a blank number, trying to dial a number like 8488449#848 if not encoded will dial 8488449 that's why you need to encode at least the '#' symbol with Uri.encode("#")
for example to dial 8488449#848, i will do the following:
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:8488449"+Uri.encode("#")+"848"));
I need to make calls in my Android app that includes "#" or "p" in the dial.
If I use the next code:
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:629941945#22412"));
startActivity(intent);
It makes the call to the number 629941945 without the # and 22412.
And if I use the next code:
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:629941945p22412"));
startActivity(intent);
It makes the call without the "p": 62994194522412.
There is a form that I can solve it?
Intent shortcutIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+Uri.encode("*111*2#")));
startActivity(shortcutIntent);
Try tel:629941945%2322412 instead of tel:629941945#22412
%23 will be replaced with #
Try to use others symbol for pause. Look at http://androidforums.com/android-applications/6733-how-do-i-dial-extension.html or http://code.google.com/p/android/issues/detail?id=7514
But! As I see threre are not one solution and this is depends of phone model
Pause is not supported in the tel URI spec.
http://www.ietf.org/rfc/rfc3966.txt
As stated in another answer %23 can be used to substitute for #.
Some phones don’t have “p” character, but “,” (comma), somewhere it is
“T” and if your phone does not have these fancy characters available,
try “*” or “#“. Hopefully one of this characters will work. Beware, on
some phones are letters case sensitive, so P can not work.
http://rekrowten.wordpress.com/2011/08/29/special-characters-in-telephone-number/
You can not parse such special numbers with an URI since these are not compliant to tel: standard. (http://www.ietf.org/rfc/rfc3966.txt Page 6ff)
You might want to use ACTION_DIAL and give the user the possibility to enter the number himself. Maybe then the phone interprets this as the pause signal p is intended for. To send such pause signals, check Alex Klimashevsky's answer.
Try using "," (comma) instead of p. No idea about "#" though, sorry.
In a similar vein to Sending Pause and DTMF input in android, I'm trying to send the pause character "," to the dialer. This works on HTC Sense phones and even on the Xoom, but not on "stock experience" phones like the Nexus One or T-Mobile G2 (and I suspect the Motorola Droid).
These phones seem to have a dialer that tries to pretty-format the number (ie adding dashes) and stop upon hitting a comma character. Interestingly, it doesn't choke on a "p" character, though it will strip out "p"s and keep adding numbers.
Here is what the ActivityManager sees:
I/ActivityManager( 92): Starting activity: Intent { act=android.intent.action.DIAL dat=tel:8883333,444 cmp=com.android.contacts/.DialtactsActivity }
I've also tried the encoded form, "tel:8883333%2C444" with no difference in behavior on these phones. I've tried "p", as mentioned, but these characters are dropped resulting in the dialers having 888-333-3444 incorrectly populated, and I'm not sure that "p" is correct anyway.
So, the question: Is there a way to specify a pause that works across most or all android dialers?
Short answer: Doesn't look like it's possible using the native dialer.
Long answer:
The native dialer in Android uses the following code to extract the number you pass in to the dialer using an Intent
if ("tel".equals(uri.getScheme())) {
// Put the requested number into the input area
String data = uri.getSchemeSpecificPart();
setFormattedDigits(data, null);
return true;
}
Within the setFormattedDigits method the number gets transformed thusly:
String dialString = PhoneNumberUtils.extractNetworkPortion(data);
Looking at the docs for extractNetworkPortion you'll notice that it, "Extracts the network address portion [where the] Network address portion is everything up to DTMF control digit separators (pause or wait).
So the code is intentionally striping out the pause character and anything that comes after it. The only alternative I can think of is to replace the dialer or use the ACTION_CALL action instead of ACTION_DIAL. That'll bypass the dialer, so it should be used with caution.
dialing pause has been comma for 30 years
If the android phone is compatible with ITUT V.250 ATS8=2 should set the delay caused by comma to 2 seconds. (it's possible that it has somehow been set to 0s)
ITUT is a great standards orgnisation, you can download their standards for free.
From the android's latin ime source code:
<!-- Pause is a comma. Check PhoneNumberUtils.java to see if this has changed. -->
<Key
android:codes="44"
android:keyLabel="Pause" />
I am not 100% sure if it's public, but you might be able to use:
PhoneNumberUtils.PAUSE
',' is the standard but HTC used 'p' in rogers magic,, have you tried with 'p'?
HTC Magic is using p
This is horrible and dangerous. Business people getting conference call emails on their phone have to constantly switch back and forth to get the number.
Just make it work like it should:
tel://+1-877-555-1212,,,2345678#
Should dial the 877 number pause then dial in the participant conference code and 'enter' (#) when selected anywhere on the phone.
It's that simple. The fact this doesn't work in Android is a iPhone sales pitch.
For future reference RFC-2806 specifies storing telephone numbers in the format:
tel:number;postd=post-dial
Where number can start with + for intentional dialling and can include - or . as a visual separator and post-dial can include numbers, upper case letters A-D, #, *, p for pause and w for wait.