test the localhost in android emulator

Localhost is device's own loopback interface, if you're trying to access your development machine use 10.0.2.2.

More about it here.