I created an app to call to number *123456789#, but when the app calls this number, Android just calls *123456789 (without the #).
Could you help me?
You simply have to encode the phone number.
String phonenumber = "*123456789#";
encodedPhonenumber = URLEncoder.encode(phonenumber, "UTF-8");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + encodedPhonenumber)));
Related
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 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
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#");
I am trying to call a USSD number from my application like this:
Uri u = Uri.fromParts("tel", "*110#", "");
Intent i = new Intent(Intent.ACTION_CALL, u);
startActivity(i);
This makes the phone app launch and call the number.
What I want is to call the USSD number without opening the phone app or atlease open it up in the background.
If the user is doing something, then he should not be disturbed. Only a notification must be generated.
any suggestions?
it is possible now since android O(api 26) with sendUssdRequest() check the docs https://developer.android.com/reference/android/telephony/TelephonyManager.html#sendUssdRequest(java.lang.String,%20android.telephony.TelephonyManager.UssdResponseCallback,%20android.os.Handler)