I know that many people asked this before I do, but I can't find any answer so got to repost it here.
So when I start the android emulator, everything is fine. But after a while, like 5 minutes, then it'll lose the internet connection, which means I can't access to the internet via browser, or my app. The only thing I can do is to restart the emulator by close it and start it again.
Any response is appreciated.
This is due to a bug in the emulator code. Basically it doesn't close UDP sockets which in turn causes "socket leak". If you monitor socket connections for the emulator-x86.exe process on your host (Winows), you will notice that the number of connections keep going up as you visit new sites on a browser for example. When the count goes beyond a point (around 100), the emulator fails to open new network connections. I have the same issue and did not find any solution so far.
I've had success using emulators that don't have the Google APIs, so maybe there is something in the pre-loaded Google API junk that is calling home using UDP sockets like @user3361886 described.
Unfortunately they have not provide an image without Google APIs for the latest (API 25). So do as much testing as possible using older versions without Google APIs, and then just test with Google APIs when you specifically need to test Google play services and/or verify your app works properly in API 25 or higher.