See: Using app-specific passwords - Apple Support
I'm not sure how you would restore contacts to an Android device -- but I don't know much about them.
Note that you can use a computer browser and log in to www.icloud.com, go to the Contacts app there and use the gear-shaped icon at lower left to select all and then to Export vCards. That does not require an app-specific password.