[TinyTut] - Getting the IMSI / IMEI (SIM/Device unique IDs)

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

[TinyTut] - Getting the IMSI / IMEI (SIM/Device unique IDs)

Postby plusminus » Sun Jan 06, 2008 7:00 pm

[TinyTut] - Getting the IMSI / IMEI (SIM/Device unique IDs)


What you learn: You will learn how read out the IMSI (International Mobile Subscriber Identity) of the SIM-Card present in your mobile and the IMEI (International Mobile Equipment Identity). The IMSI identifies with the SIM, the IMEI with the device.

Possible Scenario: You need a unique id for authentication/registration or license purposes of your Android-Activity :?: This two lines below provide you one SIM-unique ID, the IMSI and the device-unique ID the IMEI :!:

Difficulty: 1 of 5 :)

:idea: Questions/Problems: Simply post below...

Description:
An International Mobile Subscriber Identity, or IMSI, is a unique number associated with all GSM and Universal Mobile Telecommunications System (UMTS) network mobile phone users. It is stored in the Subscriber Identity Module (SIM) inside the phone and is sent by the phone to the network. It is also used to acquire other details of the mobile in the Home Location Register (HLR) or as locally copied in the Visitor Location Register. In order to avoid the subscriber being identified and tracked by eavesdroppers on the radio interface, the IMSI is sent as rarely as possible and a randomly generated TMSI is sent instead.

The International Mobile Equipment Identity or IMEI is a number unique to every GSM and UMTS mobile phone. It is usually found printed on the phone underneath the battery and can also be found by dialing the sequence *#06# into the phone.


Code: And this is how you read out the unique IMSI-ID / IMEI-ID within Android:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String myIMSI = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI);
  2. // within my emulator it returns:   310995000000000
  3.  
  4. String myIMEI = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMEI);
  5. // within my emulator it returns:   000000000000000
Parsed in 0.058 seconds, using GeSHi 1.0.8.4

Thats it :)

Regards,
plusminus
Last edited by plusminus on Tue Jan 08, 2008 3:25 pm, edited 1 time in total.
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

thanks guru....

Postby csagar » Mon Jan 07, 2008 5:35 am

hi...thanks a lot. :) .....that is it.... actually i serached it in the simutils class initially, and later on found it in the parent class telephony ...... anyway....thanks a lot for your instant reply..... this is really a happening forum for android..... your droiddraw is an amazing tool....three cheers for it!!! 8)
csagar
Junior Developer
Junior Developer
 
Posts: 15
Joined: Sun Jan 06, 2008 1:42 pm

Re: thanks guru....

Postby tum0rc0re » Mon Jan 07, 2008 7:14 am

csagar wrote:your droiddraw is an amazing tool


Btw, this tool wrote not plusminus, its author is Brendan Burns.

Nick, thanks for this tut :) It's useful for me.
JQ Soft web page:
[b][url=http://jqsoft.ru/]http://jqsoft.ru/[/url][/b]
My proffesional blog: [b][url=http://maximyudin.blogspot.com]http://maximyudin.blogspot.com[/url][/b]
Facebook: [b][url=http://www.facebook.com/maxim.yudin]http://www.facebook.com/maxim.yudin[/url][/b]
User avatar
tum0rc0re
Senior Developer
Senior Developer
 
Posts: 158
Joined: Sun Nov 25, 2007 7:15 am
Location: Moscow, Russia

Re: thanks guru....

Postby plusminus » Mon Jan 07, 2008 3:42 pm

tum0rc0re wrote:
csagar wrote:your droiddraw is an amazing tool


Btw, this tool wrote not plusminus, its author is Brendan Burns.


Told him this too, but he didn't want to listen ;)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

thnx for making the the point clear

Postby csagar » Tue Jan 08, 2008 5:54 am

hey, thanx for making the point clear..... so now i shall cheer for Burns....three cheers Burns !! :)
csagar
Junior Developer
Junior Developer
 
Posts: 15
Joined: Sun Jan 06, 2008 1:42 pm

Where IMEI and IMSI code are stored?

Postby s.semeria » Sun Mar 09, 2008 12:34 pm

Hi all,

I was wondering where those IMEI and IMSI code are stored... I need them as unique identifier, but actually they seems not, cause it seems the IMEI is always 0... is there a way to customize those codes, in a way that different instances of the emulators can have different codes?


Regards,

Stefano
s.semeria
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Jan 28, 2008 10:18 am
Location: Italy

Top

Postby plusminus » Sun Mar 09, 2008 12:40 pm

Hello s.semeria,

I don't know where the values are stored, but expect that to work on real devices.
You could easily hardcode different numbers.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby albert » Tue Feb 24, 2009 7:29 am

The following code is deprecated.

String myIMSI = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMSI);
// within my emulator it returns: 310995000000000

String myIMEI = android.os.SystemProperties.get(android.telephony.TelephonyProperties.PROPERTY_IMEI);
// within my emulator it returns: 000000000000000

In order to get IMSI and IMEI, the following code works, assuming you write the code in a Activity class.

TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String imsi = mTelephonyMgr.getSubscriberId();
String imei = mTelephonyMgr.getDeviceId();

Do not forget to set <uses-permission android:name="android.permission.READ_PHONE_STATE"/> in AndroidManifest.xml.
albert
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Feb 24, 2009 7:23 am

Postby sonbka2002 » Thu Feb 26, 2009 4:31 am

albert wrote:The following code is deprecated.

Do not forget to set <uses-permission android:name="android.permission.READ_PHONE_STATE"/> in AndroidManifest.xml.


Take care about this. If doesn't have, Can't not run.
sonbka2002
Freshman
Freshman
 
Posts: 5
Joined: Tue Feb 17, 2009 7:29 am

Postby vadimz » Wed Oct 28, 2009 3:46 pm

Any idea about how will it work in NON MOBILE Android devices?
I mean if they can be used for unique user identification there. Perhaps, there are more unique and common IDs like "device ID". I am afraid all these will be zero e.g. at Android PC.
vadimz
Developer
Developer
 
Posts: 44
Joined: Thu Jul 30, 2009 5:04 pm
Location: Moldova

Postby myshoes » Sat Oct 31, 2009 5:54 pm

vadimz wrote:Any idea about how will it work in NON MOBILE Android devices?
I mean if they can be used for unique user identification there. Perhaps, there are more unique and common IDs like "device ID". I am afraid all these will be zero e.g. at Android PC.

Yes, would love any input on the fact that these ID's don't provide anything with non-phone based installs. There is the following but what I'm seeing it is not 100% foolproof:
String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
myshoes
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon May 04, 2009 2:07 am

Postby vadimz » Sun Nov 01, 2009 4:26 pm

myshoes wrote:Yes, would love any input on the fact that these ID's don't provide anything with non-phone based installs. There is the following but what I'm seeing it is not 100% foolproof:
String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);


Yes, you are right
viewtopic.php?p=22494
vadimz
Developer
Developer
 
Posts: 44
Joined: Thu Jul 30, 2009 5:04 pm
Location: Moldova

Postby sblantipodi » Tue Apr 06, 2010 12:21 am

is there a way to get the MAC address of the Wifi board?
as far as I know all android devices support wifi, so getting Wifi MAC should be good enough...
sblantipodi
Senior Developer
Senior Developer
 
Posts: 122
Joined: Fri Mar 26, 2010 1:41 pm

Postby gaurav.gupta » Wed Apr 21, 2010 11:47 am

:cry: I doesnot work and i get error android.os.SystemProperties can be resolved to a type.

Same is the case for TelephonyProperties

Plz help i need to retrieve these details if you could tell which api to use and any reference material ..

Thanks & Regards
Gaurav Gupta
REGARDS
GAURAV GUPTA
User avatar
gaurav.gupta
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Mar 18, 2010 3:34 pm

Re: [TinyTut] - Getting the IMSI / IMEI (SIM/Device unique I

Postby Profete162 » Tue Sep 21, 2010 11:58 pm

As these numbers require an additional permission, does any of you know a way to get a unique number for each device without an extra permission in manifest?
Profete162
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Nov 27, 2009 6:07 pm

Top
Next

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests