telephony - Android making phones calls from inside & outside country -


it simple, want make feature when clicked calls number.however, if inside oman want call number , if outside want call different number.

i tried this, , know if correct way it...or have rely on else

packagemanager pm = getpackagemanager();                 boolean hastelephony = pm.hassystemfeature(packagemanager.feature_telephony);                 if(hastelephony)                 {                     telephonymanager tmanager = (telephonymanager) getsystemservice(context.telephony_service);                     if(tmanager != null)                     {                         string locale = tmanager.getsimcountryiso();                         if(locale != null && locale.tolowercase().equals("om"))                         {                             i.setdata(uri.parse("tel:800"));                         }                         else                             i.setdata(uri.parse("tel:+9687"));                     }                     else                         i.setdata(uri.parse("tel:+9687"));                 }                 else                     i.setdata(uri.parse("tel:+9687")); 

you're on right path, want call:

tmanager.getnetworkcountryiso() 

that way country of mobile network phone connected to, instead of country sim (which same).

on side note: don't need check whether device has telephony feature - if doesn't tmanager null anyway.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -