Get the current page being viewed in the browser (Possible?)

时光怂恿深爱的人放手 提交于 2019-12-22 17:59:41

问题


I would like to know Is it possible for me as an android developer to know if the browser app is currently open, and if it is, what page is being viewed? (URL?)

If so, how would I go about doing this? If not, I would also love to know so I wouldn't search anymore.

Thanks, Omri.


回答1:


Hello, I would like to know Is it possible for me as an android developer to know if the browser app is currently open, and if it is, what page is being viewed?

No, that is not possible -- it would be a privacy violation.




回答2:


I don't know, is it possible or not, to know if the browser app is currently open.

But, yes, you can get the page that is viewed. That is all the pages searched, browsed or bookmarked. And then, using that url, you can get the page.

Luckily I have done an application to parse html of page in browser.
The code to get the url of last page viewed in browser is:

Cursor c1 = Browser.getAllVisitedUrls(getContentResolver());    
Cursor c2 = Browser.getAllBookmarks(getContentResolver());    
c1.moveToFirst();    
c1.moveToPosition((c1.getCount() - c2.getCount()) - 1);    
String url = c1.getString(0);   
c1.close();   
c2.close();   

Url is what you needed.



来源:https://stackoverflow.com/questions/4470434/get-the-current-page-being-viewed-in-the-browser-possible

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