Personally I do not insist to use localhost when using device, there is no easy solution.
Just start the activity where you connect to localhost where you can use emulator. Whatever info you have to get from device can be generated with ease and can be sent to activity as parameter.