How to run USSD code in android - android

i am using dual sim phone. Now i want to run USSD code by one particular network without selecting the operator to call.
my code:
String ussdCode = "*" + "123" + Uri.encode("#");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + ussdCode)));
Response: now it was asking me to select the operator to call the ussd code. I want to run that USSD Code by that particular operator without asking.
Thank you in advance.

With Samsung devices use the below
callIntent.putExtra("simSlot", simSlot);
where simSlot is integer as 0,1

Related

sending USSD Code with special character in android

I want to send USSD code with # symbol in android kotlin
like *121*1*name#domain#
but android ignore after #. it only sending *121*1*name#
val ussdCode = "*121*1*name#domain#"
telephonyManager.sendUssdRequest(ussdCode, callback, Handler())
Try encoding the special character and append with the string. use Uri.encode("special character");
for your code you can use like -
val ussdCode = "*121*1*name" + Uri.encode("#")+ "domain" + Uri.encode("#");
I have not tested but Hope this will help you.

how to send SMS in Flash Air for Android

I am trying build an sms based application in AIR (Flash)
Got this code from an old link
str = "sms:1-415-555-1212";
var urlReq:URLReq = new URLRequest(str);
navigateToURL(urlReq);
but this one is 5 years old and lot has change and even Flash is now Animate CC
so can anyone help me in this
5 years, but still nothing changed - your code will work on modern devices.
You can use the URL with sms: - This is supported in all mobile OS:
private function sendSMS(phone:string):void
{
navigateToURL(new URLRequest("sms:" + phone));
}
For example:
navigateToURL(new URLRequest("sms:+00133234534"));
Bonus Tip!
Send a phone call: navigateToURL(new URLRequest("tel:" + phone));
Send an email: navigateToURL(new URLRequest("mailto:" + email));

Titanium: Show and Create Contact Intent

I was trying to export contacts from my application to the native android contacts.
I found the following solution here on this site: Titanium: How to add Contact in Phone book in Android?.
And it kinda works. The intent gets started. Only problem is, that android does not recognize most of the Extras i put in. So almost every field is blank. It does not matter if I replace contactModel with a simple String, the result is the same.
So i was wondering if the keys are simply wrong, but there seems no proper documentation on appcelerator. Probably something has changed over the past years or I am just missing something. Does anybody know how to do it the right way.
Code Snippet:
if (OS_ANDROID) {
var intent = Ti.Android.createIntent({
action : 'com.android.contacts.action.SHOW_OR_CREATE_CONTACT',
data : 'mailto:' + contactModel.get('contact_first_name') + ' ' + contactModel.get('contact_last_name')
});
intent.putExtra('email', contactModel.get('contact_email'));
intent.putExtra('email_type', 'Work');
intent.putExtra('phone', contactModel.get('contact_mobile_number'));
intent.putExtra('phone_type', 'mobile');
intent.putExtra('name', contactModel.get('contact_first_name') + ' ' + contactModel.get('contact_last_name') );
intent.putExtra('address', addressModel.get('address_street') + ", " + addressModel.get('address_city'));
intent.putExtra('address_type', 'Work');
Ti.Android.currentActivity.startActivity(intent);
}
Thx in advance. :)
The first parameter of putExtra() also accepts one of the constants Ti.Android.... So instead of email you would probably have to use Ti.Android.EXTRA_EMAIL.
I think you can find quite a lot in the docs, e.g. here:
EXTRA constant properties in Ti docs
EXTRA constants in Android docs
Android Intents in Ti docs

Android passing multiple numbers to SMS intent

I am getting different numbers from Contacts and passing them to SMS application. I am using the following:
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( "sms:"+numbers) ); //numbers separated with ;
intent.putExtra( "sms_body", body );
startActivity( intent );
The problem is if I separate numbers with ' ; ', it does not work on Galaxy S but works on others like HTC, Samsung Gio etc... On Galaxy S, it works if I separate numbers with comma ' , '. So how to resolve this issue?
Normally using a semicolon (';') is the right choice to separate phone numbers. So you should use this. It might be due to vendor specific adjustments or custom vendor applications that it does not work on Galaxy S for example.
I would propse to use semicolon everywhere except for Samsung devices. You unfortunately have to do this ugly vendor specific decision within your source code.
String separator = "; ";
if(android.os.Build.MANUFACTURER.contains("Samsung")){
separator = ", ";
}
// set the numbers string with the use of 'separator'
Note that the solution provided (using the os.Build.MANUFACTURER string) does not work in all situations!
I have several users that use a Samsung device which run's a Cyanogenmod version of Android. In this situation the MANUFACTURER string contains "Samsung", but the separator should be a ";" instead of the ",". I did not find a solution for this issue yet...

phone gap adding contacts problem

iam just practicing with phone gap for android app. I found a piece of code in docs.phonegap.com, regarding adding contacts
function onDeviceReady()
{
alert('onDeviceReady: PhoneGap1');
var myContact = navigator.contacts.create({"displayName": "Test User"});
alert('onDeviceReady: PhoneGap2');
myContact.gender = "male";
console.log("The contact, " + myContact.displayName + ", is of the " + myContact.gender + " gender");
}
When i run this i am getting only the alert box and the name is not added in my contacts. How to add the contacts....
Please tell me how to add data and open the device default contacts...
Simon Mac Donald has written a great blog post on contacts with PhoneGap and Android.
http://simonmacdonald.blogspot.com/2011/09/saving-contacts-with-phonegap-android.html
It should help you out as there are a few steps to it.
The quick answer for those of you searching, is that you have to call
myContact.save()
in order to persist the contact that you just created.

Categories

Resources