views:

96

answers:

3

I would like to be able to generate unique serial numbers for each Android device for use in unlocking an application. How could I do this?

EDIT:

The reason is I want to revamp a paid application and provide users who have paid for the old version, which will have a different package name, a way to obtain the full version by downloading an unlockable free version of the application. I would push an update to the old version that would generate and display the code that they could enter to turn the Free version into a fully functional version.

A: 

You can use the IMEI no for this.

Kangkan
I would not use the imei for this. Accessing the imei needs special permissions that look like your are using data that you are not supposed to use and make users suspicious. The imei is nothing that you should store off the phone unhashed.
Janusz
+1  A: 

Android already provides a licensing service for use by paid apps. Is there a reason you don't want to use this? Bear in mind that trying to lock your app to a particular phone is going to really annoy users who switch devices (Eg, all of them, sooner or later).

Nick Johnson
Added the reason for asking to question
Aymon Fournier
+1  A: 

You can use the Android id. This id should be unique to devices, but how it is set depends on the implementation of the device manufacturer.

String deviceId = Secure.getString(context.getContentResolver(),Secure.ANDROID_ID);

The Android Id may change on factory reset of the phone and the user is also able to change it on rooted phones. But if you need an id to identify your user it should be fine.

Janusz