0

I need a unique string for every device of my app. The app sends requests to the server and I need unique identifier on the server side to recognize the requester. I used the mac address of the device before but I was pointed out that the using of the mac leads to privacy violation. So I decided now to generate a string instead of using the mac.

What do you thing, can I do replace the get_mac_address() with the getSessionId() and be sure that the String will occur just once in the database?

Code:

private String get_mac_address() {
    WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiInfo wInfo = wifiManager.getConnectionInfo();
    String macAddress = wInfo.getMacAddress();
    return macAddress;
}

 public void getSessionId() {
     SecureRandom random = new SecureRandom();
        sessionId =  new BigInteger(130, random).toString(32);
      }
MrPencil
  • 934
  • 8
  • 17
  • 36
  • Do you mean 'user' or 'device'? There is a huge difference and you say 'user' but your current method (the MAC address) is really per 'device'. Lots of people have more than one device. Either way, check out [Is there a unique Android device ID?](http://stackoverflow.com/questions/2785485/is-there-a-unique-android-device-id) – Tigger Nov 29 '15 at 10:13
  • @Tigger: Yes I meant device and not user. Thanks! – MrPencil Nov 29 '15 at 10:19
  • @tigger: Can I use this AndroidId without violation privacy? Does the user have to agree this term? – MrPencil Nov 29 '15 at 10:49

1 Answers1

0

I suggest you to get to this page for some information on the android developer blog which is used to identify the app installation: http://android-developers.blogspot.in/2011/03/identifying-app-installations.html

Here is a section of using ANDROID_ID. go through it.

You can also combine ids from user and device to make your unique string. It removes the posibility of multiple users with same device id also.

Somthing like [SHA1/MD5 of user_id/user_email]_[device_id]

Go through the following question for more details on this. This will help you surely: Is there a unique Android device ID?

Community
  • 1
  • 1
kirtan403
  • 7,293
  • 6
  • 54
  • 97