Generating Device-Specific Serial Number [duplicate] Generating Device-Specific Serial Number [duplicate] android android

Generating Device-Specific Serial Number [duplicate]


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.


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 ContextAccount[] 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();


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).