Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android服务中使用WebView.findAll()_Android_Service_Webview - Fatal编程技术网

在Android服务中使用WebView.findAll()

在Android服务中使用WebView.findAll(),android,service,webview,Android,Service,Webview,我对我的服务进行了如下编程: public int onStartCommand(Intent intent, int flags, int startId) { loadVariables(); webview = new WebView(this); webview.loadUrl(url); makeNotification = notificationMaker(); result = webview.findAll(part1) > 0;

我对我的
服务进行了如下编程:

public int onStartCommand(Intent intent, int flags, int startId) {
    loadVariables();
    webview = new WebView(this);
    webview.loadUrl(url);
    makeNotification = notificationMaker();
    result = webview.findAll(part1) > 0;
    if (result == true){
        notification();
    }
    return super.onStartCommand(intent, flags, startId);
}
我想启动它,检查是否在
webview
中找到字符串part1,并发出通知,但它什么也不做

第1部分和url加载正确,通知也能正常工作(我通过在toast中打印它们来检查),因此
webview
一定有问题


是否需要在XML文件中显示它,如果需要,我认为它对服务不起作用,对吗?

webView.loadUrl是异步的。但在我的主类中,它在正常运行应用程序时工作,如果我在第6行插入==而不是>,它将返回一个通知。webView不会在服务中加载。它们必须仅在活动中使用如果您插入==而不是>,您将测试findAll是否未找到任何内容,这可能是因为尚未加载任何内容。如果没有,您是如何在服务中使用WebView的?你确定这样行吗?