问题
I'm trying to create an app that monitors all incoming traffic and blocks it if required and if necessary, replace it with traffic from elsewhere. (preferably using a filter list made up of URL's) is there any possible way to do this? I have searched Google, and stack overflow and I have not been able to find anything relevant to my needs. thank you very much for any help in advance.
回答1:
This will be tough. Android has no host file as such.
I assume you will not want to develop your own custom ROM (because there are custom ROMs that allow you to sniff and filter the packets going back and forth on an Android device).
Take a look at Broadcast Receivers. Broadcast Receivers are your best bet for that kind of functionality. They can intercept url browser calls, phone calls, SMS, etc. (assuming no other Broadcast Receivers are present with the same or higher priority).
来源:https://stackoverflow.com/questions/7439101/how-can-i-monitor-and-block-traffic-using-a-filter-list-of-urls