Android get browser's address

北战南征 提交于 2019-12-13 00:55:02

问题


Is there a way to get address from the browser that user is trying to open using some listener or something, and if the address is in the database and the address is banned, stop loading that address in the user's browser?


回答1:


Android is a flavour of the Linux operating system and what you want to do is essentially create a firewall. To allow the creation of a firewall in Linux, Netfilter is provided:

Netfilter is a set of hooks inside the Linux kernel that allows kernel modules to register callback functions with the network stack

However to provide a simpler interface to create a firewall Linux flavours typically implement iptables (essentially another layer on top of Netfilter).

iptables are the tables provided by the Linux kernel firewall (implemented as different Netfilter modules) and the chains and rules it stores. Different kernel modules and programs are currently used for different protocols; iptables applies to IPv4, ip6tables to IPv6, arptables to ARP, and ebtables to Ethernet frames.

In linux you essentially create iptable chains to allow the access to websites as well as block incoming connections.

BUT

I am not aware that iptables is implemented in Android. You would have to go digging into the source code for the Android kernel. Secondly you need to have root access to the phone.

Personally if iptables/netfilter is not implemented in the Android kernel I would look at doing so. Yes it's a lot of work but why re-invent the wheel?




回答2:


If you build a browser like application, then you have control over it. You can either block, or report that the page is opened, etc. Else, its not possible!



来源:https://stackoverflow.com/questions/15134055/android-get-browsers-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!