0

I'm making an android game which is made with a hacking theme, and I want to generate a random and unique IP address-style user ID (example xxx.xxx.xx.xx)

At the moment I know how to generate a unique ID, but it is just incremented from 1 and up.

I don't know if it is maybe only possible through php? Or even the android app's side?

Any help would be greatly appreciated!

1 Answers1

1

Try this on Android app side,

Random random = new Random();
return random.nextInt(256) + "." + random.nextInt(256) + "." + random.nextInt(256) + "." + random.nextInt(256);

See this SO thread.

Edit : To generate random numbers without repeatations, see this thread. You will have to modify it for your need though.

Community
  • 1
  • 1
K Neeraj Lal
  • 6,768
  • 3
  • 24
  • 33