Tuesday, February 15, 2011

[android-developers] figure out country in a device without SIM card

Hello Android gurus,

In my game I've got a 'global leaderboard' where people submit their high scores and check how others are doing. There I display a little flag to show where a particular player is from.
To figure that out, I use

public String getIso()
    {
        TelephonyManager tM =((TelephonyManager) mMain.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE));
        return tM.getSimCountryIso();
    }

That works nicely on any phone; however, recently people started using the new fad, tablets. Those generally do not have a SIM card, so whenever such user contacts my server I can see that getSimCountryIso() must have returned NULL ( or maybe an empty string ) and I am unable to figure out the country.

Any tips?

L.


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment