英文:
How to detect link Android device is visiting in its browser and send the url to another app?
问题
I want to create an app to detect fraud/phishing links, this app acts as an overlay over browsers, how do I read the website the browser is visiting and send it to the app so that I can send the url for analysis to the backend.
如何读取浏览器正在访问的网站并将其发送到应用程序,以便我可以将URL发送到后端进行分析?
How do I read the url from the mobile browser exactly?
我如何准确地读取移动浏览器的URL?
英文:
I want to create an app to detect fraud/phishing links, this app acts as an overlay over browsers, how do I read the website the browser is visiting and send it to the app so that I can send the url for analysis to the backend.
How do I read the url from the mobile browser exactly?
答案1
得分: 1
尝试这个:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
这对我来说运行正常。
至于缺少的 "http://",我会像这样处理:
if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;
我还可能会在用户输入 URL 时预填充 EditText,内容为 "http://"。
英文:
Try this:
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
That works fine for me.
As for the missing "http://" I'd just do something like this:
if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;
I would also probably pre-populate your EditText that the user is typing a URL in with "http://".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论