basic Universal user ID for android applications as an android project library
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Simple security-wise fool-proof method to determine a universal user ID to use in tracking of application bugs per user, analytics, etc. Provided in Android Project Library format.

Code Best Practices User ID Basics

The general idea is that we use a limited set of permissions in the AndroidManifest to allow us ot get enough information to use better user ID. Sounds simple, yet even Groupon has goofed this up.

Okay some basics, every computer machine generates a machine ID no matter what OS operates that devices. In the non phone device the mahcine ID is actually enough bits that you will not get any ID clashes per the largets amount of users per application. In phones we can can use the SIM ID as long as we take some hashing of the ID as a precaution and it to the machine ID.

There are three other edge cases. One, the emulator which will show a certain andriodID of 9774d56d682e549c which is handled in the if case to set a random machineID,obviously what else would you set it too? Some OEMs had android 2.2 devices with the same machine ID as 9774d56d682e549c and that edge cas is also detected and assigned a random Uuid.

The other edge case is what happens upon factory reset. That edge case cannot really be handled from the device so we do not worry about is so rare in a well tested robust application.

The IMEI, deviceID, used in if its an actual phone like device is also hashed.

You will also notice its facytory class to store it in shared preferences and the visibility of variables is limited to maintain a tight reign in who can see the value of any unencrypted value.


Import the APL into your IDE workspace and in your application:

onCreate{ GWSAndroidUuidFactory myUUId =new DeviceUuidFactory(context); }

Does not get any simplerr than that folks.


Copyright 2014 Fred Grott GrottWorkShop

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Development Resources

As always Google Engineers and OEM Engineers do not answer direct android application development questions by emial and so these resources are somewhat better to use for that purpose.

G+ Android Application Development Circle G+ Android Design Circle(private invite only Stackoverflow Android Area

About The Author

Fred Grott is an Android Application Engineer that develops android applications for startups and firms in the Greater Chicago area. His encyclopedia of android internals and android techniques combined with expert java and computer science skills and knowledge make short work of tough and challenging development problems for firms in the Greater Chicago area everything from mobile web applications to hybrid mobile web and native applications and all the way to android native applications.

Being an Agile Rockstar Android Developer means Fred Grott uses expert java techniques to choose what methods are effective to solve specific problems. For example, annotations performance is not robust enough just yet to fully use dependency injection to separate concerns so modifying MVC into Passive MVC is used to separate concerns such as business logic, views, and model.

He can be followed on many of his Social Profiles:
G Plus

His main websites are: Blog at Blogger
GWS site at

Contacting Author

The author can be contacted by visiting these profiles and using the contact links: <a href"" rel="me"> Profile
Google Plus Profile

Endorse The Author