![android 主机模式](https://i-blog.csdnimg.cn/blog_migrate/b683091f182ae39da54cab6347a646f3.png)
android 主机模式
![image image](https://i-blog.csdnimg.cn/blog_migrate/9ed1142f3aab303dba8711f009eb9ee4.png)
Whether you want to prevent your child from accessing Facebook or are simply sick of the advertisements that litter webpages, a custom hosts file can come in handy.
无论您是要阻止孩子访问Facebook,还是只是厌倦了乱扔垃圾网页的广告,都可以使用自定义托管文件。
Note: This requires a rooted Android device.
注意:这需要植根的Android设备。
如何在Android上编辑主机文件 (How to Edit the Hosts File on Android)
The easiest way to edit the hosts file on your device is to use the Android Debug Bridge, so go ahead and set it up. Once you’re done, navigate into the folder where ADB is located and type cmd into the location bar, which will open a command prompt in the current folder.
在设备上编辑主机文件的最简单方法是使用Android调试桥, 因此请继续进行设置 。 完成后,导航到ADB所在的文件夹,然后在位置栏中键入cmd,这将在当前文件夹中打开命令提示符。
![image image](https://i-blog.csdnimg.cn/blog_migrate/4cf02a9814adc3b1340e3720c197cf26.png)
Once the command prompt opens run the following command to see what devices are attached to your PC.
打开命令提示符后,运行以下命令以查看PC上连接了哪些设备。
adb devices
adb设备
![image image](https://i-blog.csdnimg.cn/blog_migrate/d07dd4b5142b393389375fd4ecf17a95.png)
Next you need to download the host file from your device so you can edit it.
接下来,您需要从设备下载主机文件,以便对其进行编辑。
adb pull /system/etc/hosts F:\hosts
亚行拉/ system / etc / hosts F:\ hosts
![image image](https://i-blog.csdnimg.cn/blog_migrate/bf60ae77800a9646d978e0b5f89ac125.png)
Then navigate to where you saved the file and open it with notepad.
然后导航到保存文件的位置,然后使用记事本打开它。
![image image](https://i-blog.csdnimg.cn/blog_migrate/43778cbbd39607eb4ef0162a7d924fbc.png)
Now comes the fun part: adding the host entries. Really, you can do anything you want for example, you can use your host file to block ads from appearing on websites instead of using an app like AdBlocker, or in our case we can just block a website like FaceBook by redirecting it to localhost – you will have to search around to get the exact domains to block. When you’re done adding the entries don’t forget to save the file.
现在来了有趣的部分:添加主机条目。 确实,您可以做任何想做的事,例如, 您可以使用主机文件阻止广告在网站上展示,而不必使用AdBlocker之类的应用程序,或者在我们这种情况下,我们可以通过将FaceBook重定向到本地主机来阻止网站,例如–您将不得不四处搜索以获取要阻止的确切域。 完成添加条目后,别忘了保存文件。
![image image](https://i-blog.csdnimg.cn/blog_migrate/034ef68b888d74fa2102d0f41bb26bc6.png)
Finally you will need ADB to push the file back to your device.
最后,您将需要ADB将文件推送回设备。
adb push F:\hosts /system/etc/
亚行推送F:\ hosts / system / etc /
![image image](https://i-blog.csdnimg.cn/blog_migrate/2acdc396a4b31adaa7fef4206387c704.png)
That’s all there is to it. Now I can’t browse to Facebook from my device.
这里的所有都是它的。 现在,我无法从设备浏览到Facebook。
![Screenshot_2013-03-11-20-19-34 Screenshot_2013-03-11-20-19-34](https://i-blog.csdnimg.cn/blog_migrate/13130752c987c822ee55d6ac7162a5b4.png)
翻译自: https://www.howtogeek.com/140576/how-to-edit-the-hosts-file-on-android-and-block-web-sites/
android 主机模式