So I'm trying to send a number via Intent.ACTION_DIAL ending with # i.e for example *123#. But when the Android Dialer app is started, there is only *123 (# is missing).
I'm using following code to trigger the Dial Application of Android.
Uri number = Uri.parse("tel:*124#");
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
Anticipated Thanks!!
.
You need to properly encode the hash tag (#). In your URL requests it should be %23, so replacing it with %23 will do the trick.
Uri number = Uri.parse("tel:*124%23");
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
You can also let URI do the encoding:
String encodedPhoneNumber = String.format("tel:%s", Uri.encode("*1234#"));
Uri number = Uri.parse(encodedPhoneNumber);
Intent callIntent = new Intent(Intent.ACTION_DIAL, number);
context.startActivity(callIntent);
The answer could be related with this link
initiate a phone call on android with special character #
This line could be the key
Uri.parse("tel:"+Uri.encode("*124#"));
Related
I want to open my phone dialer .But it shows error. I have declared permissions for CALL_PHONE on Android Manifest and also declared class in Android Manifest.
case R.id.action_call:
Log.d("Action_call","INside Action call");
Intent dialer = new Intent(Intent.ACTION_DIAL);
startActivity(dialer);
return true;
You don't need any permissions for ACTION_DIAL Intent. So remove CALL_PHONE permission from AndroidManifest.xml.
You have not pass any number to fire dial Intent.
Use tel: followed by the phone number as the value passed to Uri.parse():
Try this code.
String number = "1234567890";
Uri number = Uri.parse("tel:" + number);
Intent dial = new Intent(Intent.ACTION_DIAL);
dial.setData(number);
startActivity(dial);
EDIT:
You can first check whether telephony is supported on device
private boolean isTelephonyEnabled(){
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
return tm != null && tm.getSimState()==TelephonyManager.SIM_STATE_READY
}
I hope it helps!
Use Uri to parse number..
Intent call = new Intent(Intent.ACTION_DIAL);
call.setData(Uri.parse("tel:"+phone)); //String phone
startActivity(call);
Use try/catch.
Use Uri to parse number.
Don't need any permissions for ACTION_DIAL intent.
try{
Intent call_intent = new Intent(Intent.ACTION_DIAL);
call_intent.setData(Uri.parse("tel:"+phone_number));
startActivity(call_intent);
}catch(Exception e){
}
I'm using the following code to make a call in Android but I would like to hide the number being called, and not save it in the call log. Is it possible?
String num="xxx-xxx-xxx";
String number = "tel:" + num.trim();
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
startActivity(callIntent);
I am trying to send SMS to multiple recipients viaINTENT. I tried the following to do it:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra("sms_body", etmessage.getText().toString());
intent.setData(Uri.parse("smsto:" + returnedItems));
intent.setType("vnd.android-dir/mms-sms");
mcontext.startActivity(intent);
Where returnedItems is of Contact Numbers
But the problem is that my recipients numbers are not setting on TO section on SMS INTENT where TEXT is displayed on TEXT section.
Make sure that the numbers are seperated by ; .
Intent smsIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:1234456;234567"));
smsIntent.putExtra("sms_body", etmessage.getText().toString());
startActivity(smsIntent);
always works for me!
Did you tried below ?
Intent mIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:999999;888888"));
I also found out ";" is not working in Samsung device. You have to add "," instead of ";" for samsungs devices.
Intent mIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:999999,888888"));
Also check this answer
Intent smsIntent = new Intent(Intent.ACTION_SENDTO,Uri.parse("smsto:" + pointsList));
smsIntent.putExtra("sms_body", "Hi Friends & Families, My Location is feeling unsafe in this location");
startActivity(smsIntent);
pointsList is something like ArrayList, for example [8777675673,8566463454,7776666664].
It is working fine.
I have solved this by the following way.
Intent intent = new Intent(Intent.ACTION_SEND);
String numbers = "1234567890;9876543210;453678920"
intent.putExtra("address", numbers);
context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_image)));
The numbers are separated by semi-colon (;). I read in some mobile phones the numbers need to separated by comma (,).
Hope this will help.
I need to show/interact with a new contact before create it, and I need a simple way to add it to the phone contacts.
this is the code I use:
String contactPhone = "33333333";
Uri contactUri = Uri.parse(String.format("tel: %s", contactPhone));
Intent addContactIntent = new Intent(
ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, contactUri);
addContactIntent.putExtra(ContactsContract.Intents.Insert.NAME, "FirstName" );
addContactIntent.putExtra(ContactsContract.Intents.Insert.COMPANY,"CompanyName");
addContactIntent.putExtra(ContactsContract.Intents.Insert.PHONE,contactPhone);
addContactIntent.putExtra(ContactsContract.Intents.Insert.EMAIL,"contact#email.com");
startActivity(addContactIntent);
and this is the result. The problem is that the Intent show me only the Phone instead all the info added.
ContactsContract.Intents.Insert.ACTION if you want to interact before create it:
Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION,ContactsContract.Contacts.CONTENT_URI);
intent.putExtra(ContactsContract.Intents.Insert.NAME, getName());
intent.putExtra(ContactsContract.Intents.Insert.COMPANY, getCompany());
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, getEmail());
intent.putExtra(ContactsContract.Intents.Insert.PHONE, getPhone());
intent.putExtra(ContactsContract.Intents.Insert.POSTAL, getAddress());
startActivity(intent);
This works pretty well. I hope this will help you.
This site (http://wiresareobsolete.com/2011/10/simplifying-interaction-with-contacts/) shows and gives examples) that SHOW_OR_CREATE_CONTACT can only trigger off "tel" or "mailto"/email for searches.
I'm trying to make a call directly like this
String url = "tel:" +"029870125,198#";
Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse(url));
but the problem is that Android is sending 198 as dtmf, but the # is not being sent. Is there any special mechanism needed to send # as dtmf?
Intent intentCallForward = new Intent(Intent.ACTION_CALL);
Uri uri = Uri.fromParts("tel", phoneNumber, "#");
intentCallForward.setData(uri);
startActivity(intentCallForward);