Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Device-Specific Serial Number [duplicate]

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.

like image 914
Aymon Fournier Avatar asked Aug 12 '10 05:08

Aymon Fournier


People also ask

Can 2 phones have the same serial number?

Model numbers, yes. Can 2 different manufacturers have the same serial number? It doesn't take multiple manufacturers. Each different factory or product can reuse serial numbers.

Does each phone have a unique serial number?

In Android devices how is the unique Serial number is assigned to each device? Most of the Samsung devices have a unique serial number on each device.

Can you track a device by serial number?

The IMEI or MEID, together with the serial number, won't help directly track the device. The same thing goes for apps that claim they can get a phone location by number only. Without direct access or connection to the cell phone at hand, the phone number won't be useful at all.


2 Answers

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.

like image 86
Janusz Avatar answered Sep 24 '22 21:09

Janusz


why not using ther google account name? is easy to get and needs only a simple request on the manifest file. they will have purchased the license with gplay, so the g+ account name should be enough...

in the manifest:

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

to retrieve the account name:

AccountManager am = AccountManager.get(this); // "this" references the current Context

Account[] accounts = am.getAccountsByType("com.google");

to retrieve the name:

accounts[0].name

i write a simple alert to make me sure i have found an account here the whole code:

Account[] accounts = am.getAccountsByType("com.google");
    AlertDialog.Builder miaAlert = new AlertDialog.Builder(this);

    miaAlert.setTitle("i found an account name!");
    miaAlert.setMessage(accounts[0].name);
    AlertDialog alert = miaAlert.create();
    alert.show();
like image 21
Matteo Bononi 'peorthyr' Avatar answered Sep 24 '22 21:09

Matteo Bononi 'peorthyr'