Type a phone number intent - java

How can I make my app type a given phone number without calling? I use:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + phone));
startActivity(callIntent);
But that statement makes a call too.

Replace Intent.ACTION_CALL with Intent.ACTION_DIAL

You're using ACTION_CALL. You need to use ACTION_DIAL instead.
Intent callIntent = new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:" + phone));
startActivity(callIntent);

Related

send mms with multiple files to multiple contacts

I want to send 2 vcard files to 2 contacts with intent:
Intent sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, savedFile);
String numbers = vCardElements.get(0).getPhone_1() + ";" + vCardElements.get(1).getPhone_1();
sendIntent.putExtra("address", "1231213;13232132");
sendIntent.setType("text/x-vcard");
startActivity(sendIntent);
I have tried with this but it's asking me to select the recipients but I want to pass that in the intent

android, Can I forward phone number data to google duo?

Intent intent = getPackageManager().getLaunchIntentForPackage("com.google.android.apps.tachyon");
intent.setData(Uri.parse("tel:" + "phonenumber"));
startActivity(intent);
I could not pass the data to 'Google duo' app in the same way
Is there a way?
Try this
Intent duo = new Intent("com.google.android.apps.tachyon.action.CALL");
duo.setData(Uri.parse("tel: " + phoneNumber));
duo.setPackage("com.google.android.apps.tachyon");
startActivity(Intent.createChooser(duo, "Duo is not installed."));

Android code to dial or calll a string containing alphabets *123*abc# instead of numbers (*123#)?

I’m unable to dial or call a string containing alphabets in android.
For Example:
I want to dial a string *123*abcd#.
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+"*123*abcd#")); //This string is not getting dialed
try
{
startActivity(callIntent);
}
catch (android.content.ActivityNotFoundException ex)
{
Toast.makeText(getApplicationContext(),"yourActivity is not founded",Toast.LENGTH_SHORT).show();
}
String *123*abcd# is not getting dialed or called. Please help to solve the same.
String s = "*123*abcd#";
if ((s.startsWith("*")) && (s.endsWith("#"))) {
callstring = s.substring(0, s.length() - 1);
callstring = callstring + Uri.encode("#");
}
Intent i = new Intent(android.content.Intent.ACTION_CALL, Uri.parse("tel:" + callstring));
startActivity(i);
your need to encode the # before using it above code will do the trick.
To use Intent.ACTION_CALL you need to add Permission
<uses-permission android:name="android.permission.CALL_PHONE"/> and since its a Dangerous permission you need to handle it Runtime for Android 6 and above.
You can rather use Intent.ACTION_DIAL which doesnt require any permission and will open the Phone app with the given number typed already, the user has to initiate the call.
Here is how to achieve this.
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:*123*abcd#"));
startActivity(intent);

Get only digits from input and call that number Android

Okay, I am creating an android app, I do like to get the number from an input here mostLikelyThingHeard unfortenately my code doesn't work for some reason.
For example when the user says: bel 0612345678
The dialer has to call 0612345678
String one = "bel";
if (mostLikelyThingHeard.contains(one)) {
String numbers = mostLikelyThingHeard.replaceAll("[^0-9]", "");
Intent call = new Intent(Intent.ACTION_DIAL);
call.setData(Uri.parse("tel:" + numbers));
tts.speak(numbers + " wordt gebeld.",
TextToSpeech.QUEUE_FLUSH, null);
found = true;
}
I also added the right permissions in AndroidManifest.xml, I guess the code is wrong.
You need to get numbers from String like this:
String numbers = mostLikelyThingHeard.replaceAll("[^\\d]", "");
To call that number, you can use ACTION_CALL. ACTION_DIAL will just open a dialer screen with that number. Also, you have initialized intent, but you are missing call to startActivity(intent)
Intent call = new Intent(Intent.ACTION_DIAL);
call.setData(Uri.parse("tel:" + numbers));
startActivity(call);
Hope this helps.
Can you try this
Intent.ACTION_CALL
and make sure that you are using this before application tag in manifest file
<uses-permission android:name="android.permission.CALL_PHONE" />
You can use regex and delete non-digits.
str = str.replaceAll("\\D+","");
Try this one..
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + yours_numbers_values));
startActivity(intent);
String one = "bel";
String mostLikelyThingHeard="bel 0612345678";
if (mostLikelyThingHeard.contains(one)) {
String numbers = mostLikelyThingHeard.replaceAll("[^0-9]", "");
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+Uri.encode(numbers.trim())));
startActivity(callIntent);
tts.speak(numbers + " wordt gebeld.",
TextToSpeech.QUEUE_FLUSH, null);
found = true;
}
And in Manifest add permission
<uses-permission android:name="android.permission.CALL_PHONE" ></uses-permission>

Make a Call in on number followed by # key

I am working on the calling app where I make call on button click but if the number just followed by # then it does not take the # key at the last of phone number.
For Example if I want to make a call on *123# from app then it only shows *123 in the calling screen in phone. Please suggest me where I am going wrong.
Here is my code for call on *123# on button click.
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + phoneNumber));
callIntent.setData(Uri.parse("tel:" + "*123#"));
startActivity(callIntent);
try this...
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ Uri.encode("*123#")));
startActivity(callIntent);
You need to escape the # as a URI entity: %23

Categories

Resources