To check the balance first i have to make a call *xxx# and then i get a response with the multiple options to choose from and after i input the particular number i get the balance.
What code can i use for the same in my android app?
Dialing *xxx*x# is giving me error.
Below is my code which works fine for the *xxx# calls:
String encodedHash = Uri.encode("#");
String ussd = "*" + encodedHash + lCallNum + encodedHash;
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + ussd)));
This works for me:
private Uri ussdToCallableUri(String ussd) {
String uriString = "";
if(!ussd.startsWith("tel:"))
uriString += "tel:";
for(char c : ussd.toCharArray()) {
if(c == '#')
uriString += Uri.encode("#");
else
uriString += c;
}
return Uri.parse(uriString);
}
Then in work code:
Intent callIntent = new Intent(Intent.ACTION_CALL, ussdToCallableUri(yourUSSDCodeHere));
startActivity(callIntent);
Don't forget to add permission it will solve skype problem:P
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
String ussd = "*XXX*X" + Uri.encode("#");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + ussd)));
this works perfect with me. just place the first bunch as it is then encode the # to make it have a complete *XXX*X#. this will definitely be of help
Important thing to remember :
If your are targeting Android Marshmallow (6.0) or higher then you need to request Manifest.permission.CALL_PHONE permission at runtime
Use this code, it works
Intent callIntent = new Intent(Intent.ACTION_CALL);
String ussdCode = "*" + 2 + Uri.encode("#");
callIntent.setData(Uri.parse("tel:" +ussdCode));
if (ActivityCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(callIntent);
Add this line in Manifest file too
<uses-permission android:name="android.permission.CALL_PHONE" />
You can use this code. It works for me:
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(Uri.parse("tel:" + "*947") + Uri.encode("#")));
startActivity(intent);
Related
I want to do this for my school project I want call from my app to show imei number so I want # also to be copied to phone call.But when I am executing the below code only the * is copied to phone call area
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "*#06#"));
startActivity(intent);
in order to call USDD codes you have to use something like this :
String code = "*" + Uri.encode("#") + "06" + Uri.encode("#");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + code)));
and don't forget to use the call permission in your manifest :
<uses-permission android:name="android.permission.CALL_PHONE"/>
The below code makes calls within android however, the # at the end of the number is removed and the android calls the number without it, is there a way to specify that android should keep the # at the end of the number cause I need it in this case?
Intent startCall = new Intent(Intent.ACTION_CALL);
Uri uri = Uri.parse("tel:*001203#");
startCall.setData(uri);
startActivity(startCall);
Android Manifest has the below permissions.
<uses-permission android:name="android.permission.CALL_PHONE"/>
Just use this snippet on clicking :
call.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String s = Uri.encode("*001203#");
Intent callIntent = new Intent(Intent.ACTION_DIAL);;
callIntent.setData(Uri.parse("tel:"+s));
startActivity(callIntent);
}
});
String hash = Uri.encode("#");
String ussd = "*" + hash + "001203" + hash;
startActivityForResult(new Intent("android.intent.action.CALL",Uri.parse("tel:" + ussd)), 1);
this is the workaround.
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" />
Need to make calls from my application, without invoking the default dialer Activity, i.e. my application's activity should complete the dial-out, conversation and hang-up operations.
Note that the usual way of invoking the default dialer Activity done as follows, is not what I need:
String nber = phone.getText().toString();
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + nber));
startActivity(callIntent);
Try this
String nber = "tel:" + phone.getText().toString().trim();
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(nber));
startActivity(callIntent);
And give Manifest permission
<uses-permission android:name="android.permission.CALL_PHONE" />
Intent calltoDoctor = new Intent(Intent.ACTION_CALL);
calltoDoctor.setData(Uri.parse("tel:" + personalInformation.getEmgyno()));
startActivity(calltoDoctor);
Add the permission in manifest.
<uses-permission android:name="android.permission.CALL_PHONE" >
try this
My app currently does not produce the final "#" at the end of AT&T's USSD code for checking data use (Which is supposed to be *3282#)
Here is my code:
public void callATT(View view){
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "*3282#"));
startActivity(intent);
}
Everytime it calls it just calls "*3282"
Please help me,
Thanks in advance
-Tucker
Try this, I did not test it, but should work.
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode("*3282#")));
startActivity(intent);
public Uri USSDToCallableUri(String ussd) {
String uriString = "";
if(!ussd.startsWith("tel:"))
uriString += "tel:";
for(char c : ussd.toCharArray()) {
if(c == '#')
uriString += Uri.encode("#");
else
uriString += c;
}
return Uri.parse(uriString);
}
Then Set This :
Intent callIntent = new Intent(Intent.ACTION_CALL, USSDToCallableUri(USSDCodeHere));
startActivity(callIntent);
Simply Use this method....
String encodedHash = Uri.encode("#");
String ussd = "*123"+ encodedHash;
startActivity(new Intent(Intent.ACTION_CALL, Uri
.parse("tel:" + ussd)));enter code here
Try something like this . Tell me it works or not
String phone = "*3282#";
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", phone, null));
startActivity(intent);