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
Post a Comment