Not able to make a call when #31# is added - android

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"));

Related

Android Speech to text for number and email ID

I am using Android Speech to text for speech recognition.
final Intent sttIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
final String language = config.getLanguage().replace('-', '_');
sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
sttIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, language);
sttIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
sttIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, context.getPackageName());
// WORKAROUND for https://code.google.com/p/android/issues/detail?id=75347
sttIntent.putExtra("android.speech.extra.EXTRA_ADDITIONAL_LANGUAGES", new String[]{language});
return sttIntent;
I am having problem while getting phone number and email id.
It is not giving proper results.
Suppose if user say "triple two triple three five hundred one"
In this case STT should give me 222333501, but it is giving some number and string as result.
Suppose if user say "abc_cde#gmail.com", in this case also it is giving at the rate of and underscore as strings.
Is there any native way to solve this problem.
I have referred a java utility Convert words to number to convert string to number if valid but i am not sure that would work in all cases.
Any help is appreciated.

How do I give the user the choice of programs with which SIM card to 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.

Dial one show another phone number in Android Phone application

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!

Android How to make a call that includes "#" or "p" in the dial?

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.

How do I get the dialer to open with phone number displayed?

I don't need to call the phone number, I just need the dialer to open with the phone number already displayed. What Intent should I use to achieve this?
Two ways to achieve it.
1) Need to start the dialer via code, without user interaction.
You need Action_Dial,
use below code it will open Dialer with number specified
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:0123456789"));
startActivity(intent);
The 'tel:' prefix is required, otherwhise the following exception will be thrown:
java.lang.IllegalStateException: Could not execute method of the activity.
Action_Dial doesn't require any permission.
If you want to initiate the call directly without user's interaction , You can use action Intent.ACTION_CALL. In this case, you must add the following permission in your AndroidManifest.xml:
<uses-permission android:name="android.permission.CALL_PHONE" />
2) Need user to click on Phone_Number string and start the call.
android:autoLink="phone"
You need to use TextView with below property.
android:autoLink="phone"
android:linksClickable="true" a textView property
You don't need to use intent or to get permission via this way.
Pretty late on the answer, but if you have a TextView that you're showing the phone number in, then you don't need to deal with intents at all, you can just use the XML attribute android:autoLink="phone" and the OS will automatically initiate an ACTION_DIAL Intent.
Okay, it is going to be extremely late answer to this question. But here is just one sample if you want to do it in Kotlin.
val intent = Intent(Intent.ACTION_DIAL)
intent.data = Uri.parse("tel:<number>")
startActivity(intent)
Thought it might help someone.
As #ashishduh mentioned above, using android:autoLink="phone is also a good solution. But this option comes with one drawback, it doesn't work with all phone number lengths. For instance, a phone number of 11 numbers won't work with this option. The solution is to prefix your phone numbers with the country code.
Example:
08034448845 won't work
but +2348034448845 will
<TextView
android:id="#+id/phoneNumber"
android:autoLink="phone"
android:linksClickable="true"
android:text="+91 22 2222 2222"
/>
This is how you can open EditText label assigned number on dialer directly.
You can call Intent following this:
String number = "0123456789";
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);
A helper function for someone using kotlin:
fun openDialPad(context: Context, phoneNum: String) {
val intent = Intent(Intent.ACTION_DIAL)
intent.setData(Uri.parse("tel:$phoneNum"))
context.startActivity(intent)
}

Categories

Resources