How to do an international call? - android

I am using this:
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
startActivity(callIntent);
finish();
to do phone calls and it works great, but now I have to do some international calls from the app, where I should use the plus' sign (+) to identify the country (ex: +01198765432)
How may I do this without get any error?

You need to ad "+" sign in phone number:
Like this:
String phone="+123456789"
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+phone));
startActivity(callIntent);

Related

Android : How do I integrate whatsapp calling

Is there any way to direct call to a number by whatsapp from another application?
I have tried to redirect for messaging by using below code and is working fine.
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(Intent.createChooser(i, ""));`
Is there any similar way for calling ?
I am not sure as I have not test this but hope this will work,
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + number));
callIntent.setPackage("com.whatsapp");
startActivity(callIntent);
And don't forget below permission in menifest file
<uses-permission android:name="android.permission.CALL_PHONE" />

Intent.ACTION_DIAL with number ending with #

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

How to make a phone call without saving the number?

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

Send SMS to multiple recipients via Intent

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.

How to dial number with special characters using intent Android?

I am trying the below code to dial a number, but it always dail as *111
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:*111#"));
startActivity(callIntent);
Please help i am trying to learn android..
Thanks friends..
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ Uri.encode("*111#")));
startActivity(callIntent );
Happy Coding :)

Categories

Resources