检查页面/ web视图包含特定单词(机器人)视图、机器人、单词、页面

2023-09-04 04:09:51 作者:掵中注定

我创建一个应用程序,我想给一个通知给用户,如果一个网页(其中显示取消类)包含了你在课堂上。 如何才能做到这一点?我一定要使用的WebView 并重新加载的背景每隔x分钟,并检查它是否包含某些词,如果确实如此,给一个通知?如果这是这样,我怎么检查某些单词中的的WebView

I am creating an application, and I would like to give a notification to the user if the a webpage (which displays canceled classes) contains the class you're in. How can this be done? Do I have to use a webview and reload every x minutes on the background and check if it contains certain words, and if it does, give a notification? And if this is the way, how do I check for certain words within a webview?

推荐答案

这是很容易可行的web视图,不需要不必要的code。下面code将查找字符串(你还可以设置 FindListener 通知你,如果/当找到字符串,我还没有使用它,但它的存在):

This is easily doable in the WebView, no unnecessary code needed. The following code will find the string (you can also set a FindListener to inform you if/when the string is found, I haven't used it but it's there):

String string = "text you want to find";
webview.findAll(string); //works for API levels 3 - 16
webview.findAllAsync(string); //works for API levels 16 and up

正如你看到的,你必须,如果你想支持低于16 API级别都具有相同的监听器,但这样你只需要一个倾听者使用这两种方法,检查上面的链接。

As you see, you'll have to use both methods if you want to support API levels below 16. Both have the same listener though so you only need one listener, check the link above.