I tried do the below for a phone call intent and I still keep getting the "#" removed from the number been called. Please see code below... The # at the end get translated into a %23 on printing out the contents of the string to a console. I am testing on a Samsung S4 phone which then generates a USSD code error running. Is there something wrong with the phone or the code below
Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);
phoneCallIntent.setData(Uri.parse("tel:" + Uri.encode("*222*"+ rechargeNumber + "#");));
startActivity(phoneCallIntent);
don't use Uri.encode().
Use the following code. I think it will help you.
String uri = "tel:" +"*222*"+ rechargeNumber + "#" ;
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
startActivity(intent);
Intent you're looking for is android.intent.action.CALL_PRIVILEGED.
This might be helpful to you
using android dialer in 3rd party app
Related
I would like to be able to pass commas ',' into an Action_dial intent. A comma is used for a pause when pressing numbers for an automated phone menu system.
These can be placed in numbers in Contacts and it will work fine but when trying to Parse or Encode a URI to pass this into the Action_Dial intent, it passes the number in right up until the ',' and then will not pass anything after the ','.
I have tried several different ways of doing this several different ways.
Such as...
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:14051234567,,3,1"));
startActivity(intent)
and..
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.fromParts("tel", "14051234567", ","));
startActivity(callIntent);
and
Intent callIntent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:" + Uri.encode("14051234567")+ Uri.encode(",")));
and every other way that I've found here on StackOverflow.
Is there a way to make this happen?
EDIT-
Maybe this can't be made to work?? I just ran across this Android Bug report that was closed by Google but not ever fixed. Lame Google.
https://code.google.com/p/android/issues/detail?id=7993
I need to make automatic phone call app with this two character (comma and hash).
I try with this method. If so, all character behind hash is not called.
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" +"131#3131,,,44"));
startActivity(intent);
So, I try with this method again. Then, all number behind comma is not called. May I know how to do?
Intent out = new Intent();
out.setAction(Intent.ACTION_DIAL);
out.setData(Uri.parse("tel:" + Uri.encode("+3943#333,,23")));
startActivity(out);
Here is the answer (copied)
Uri.parse(String.format("tel:%s", Uri.encode(number)))
Source Intent.ACTION does not dial after first # sign
I'm a new android application programmer.
I created a button in my application that calls a number ie. *144# but it keep ignoring the # and dialing *144 only.
How do i ensure it calls the whole number?
Code Snippet:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:*144#"));
startActivity(callIntent);`
Url encode it.
String number = "tel:*144%23";
callIntent.setData(Uri.parse(asd));
Or if you need a more general approach (like if you numbers change...) - encode the data part of the URI with a URLEncoder.
String number = "tel:"+ URLEncoder.encode("*144#");
....
Simple use Uri encode :
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ Uri.encode("*144#")));
startActivity(callIntent);
You can try this:
Intent callIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:*144" + Uri.encode("#")));
startActivity(callIntent);
it worked for me.
# is a special character that sends command to operator. I don't think that you can actually call any number ending with #.
Am developing functionality in which i wanted to Intent.ACTION_DIAL.
Below is the code which i have tried so far.
Intent callIntent = new Intent(Intent.ACTION_DIAL);
String str = "tel:xxxxxxxxxx"; callIntent.setData(Uri.parse(str));
context.startActivity(callIntent);
However facing below two problems
1) if i tried to retrieve the imei number using "tel:#06#" then it will open the device dialer with '' only. "#06#" is not appearing there.
2) It asks the user to press call button. I dont want user to press the call button. is there any API which will allow me to directly execute "tel"*#06# kind of code from application itself.
EDITED:
I have tried below answer. its invoking dialer with "*#06#" but not showing the IMEI number of the device. if i press the same from device dialer and it showing IMEI number instantly.
All i want is to show the IMEI kind of codes from Application.
Intent callIntent = new Intent(Intent.ACTION_CALL);
String encodedHash = Uri.encode("#");
String ussd = encodedHash + "06" + encodedHash;
startActivityForResult(new Intent("android.intent.action.CALL",
Uri.parse("tel:" + ussd)), 1);
and give this permission in android menifest
<uses-permission android:name="android.permission.CALL_PHONE" />
I found a problem which I can't find solution, maybe someone has seen this before?
I use this to perform a call, now if the call is a special number such as *111#, the character # is not sent to the activity, resulting in a call to *111 without the # character.
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
Anyone understand what happens?
You should url-encode your tel:*111#:
String telUri = "tel:" + Uri.encode("*111#");