tags:

views:

122

answers:

2

Is there a unique ID that is given to Android handests that is available through the SDK?

I want to provide a web-service with actions that can only be performed once per resource per user. Maybe there is a different way to go about this. Any ideas?

+5  A: 

Use the phone Imei as described here: http://www.androidsoftwaredeveloper.com/2009/04/02/how-to-get-the-phone-imei/

String imei = TelephonyManager.getDefault().getDeviceId();
if (TextUtils.isEmpty(imei)) {
   return "";
}

You need the read phone state permission to access this data. So you have to add

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

to your manifest file.

KevinDTimm
Great! Exactly what I was looking for. Sometimes the search term escapes me...
Adam Driscoll
Be aware that this permission will be shown to the user during installation and that privacy concerned users may down rate your app for asking for access for the imei. The imei is a type that normally should not be accessed and transmitted to a server lightly. Maybe use a hash of the imei or something instead of saving it of somewhere else. Look at this blog post about privacy and data etc.: http://android-developers.blogspot.com/2010/08/best-practices-for-handling-android.html
Janusz
Cool. Thanks!!!
Adam Driscoll
Neil Traft
+2  A: 

Use the IMEI for identifying handsets. This is one of the most reliable source.

TelephonyManager.getDefault().getDeviceId();
Ragunath Jawahar
Will this return the MEID on CDMA?
Adam Driscoll
I haven't tried it on CDMA, just try it out. Might be MEID.
Ragunath Jawahar