Reputation: 21
Is it possible to check device unique id and compare with hardcoded value.If device unique id doesn't match with hardcoded value stop installation. Iam trying to make app installable in my device only.
Upvotes: 2
Views: 436
Reputation: 19263
You can't prevent users from installing the app (if they already have an APK/app bundle), you may only introduce some circumstances and check them on start. If they aren't fulfilled then simply finish()
your Activity
or show some prompt.
Check out best practices for obtaining a proper "unique ID", but keep in mind that in fact in Android there is no such value, every variable pointed under link may change in some circumstances, e.g. app reinstall, factory reset, system update, etc.
Upvotes: 3
Reputation: 841
It's a bit complex since Android doesn't have a reliable unique ID. For me the best way is to use the Secure Android ID that is generated on the device first boot.
To get:
String androidId = Settings.Secure.getString(getContentResolver(),
Settings.Secure.ANDROID_ID);
Keep in mind that if you factory reset the device it will be regenerated so you have to change the hardcoded part in your app.
Upvotes: 0