Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.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 如何通过处理程序从IntentService多次调用WebView活动?_Android - Fatal编程技术网

Android 如何通过处理程序从IntentService多次调用WebView活动?

Android 如何通过处理程序从IntentService多次调用WebView活动?,android,Android,我有一个IntentService,它正在解析某个xlm文件以创建html文件。我已经用一些模板创建了html文件。但问题是,我需要为从文件解析的每个“媒体”节点更改html文件。然后根据新的传入类型,我必须创建一个新的对应html文件,通过WebView查看 到目前为止,我尝试创建一些处理程序并将意图传递给WebView类。(我没有通过捆绑包发送任何数据。我只是在我的服务类中创建html文件,然后从WebView调用该文件。)这种想法第一次奏效。然而,在第一次媒体播放结束后,我无法再次调用相同

我有一个IntentService,它正在解析某个xlm文件以创建html文件。我已经用一些模板创建了html文件。但问题是,我需要为从文件解析的每个“媒体”节点更改html文件。然后根据新的传入类型,我必须创建一个新的对应html文件,通过WebView查看

到目前为止,我尝试创建一些处理程序并将意图传递给WebView类。(我没有通过捆绑包发送任何数据。我只是在我的服务类中创建html文件,然后从WebView调用该文件。)这种想法第一次奏效。然而,在第一次媒体播放结束后,我无法再次调用相同的活动。 调用WebView的代码如下所示:

if(counter == 0){
    createDir(); //function to create html file with corresponding date
    Intent sender = new Intent(getApplicationContext(), webLoader.class);
    //System.out.println("here");
    sender.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(sender);
}
else
{
    //System.out.println("entering?");              
    System.out.println(durationOfMedi);

    new Handler().postDelayed(new Runnable() {

        public void run() {
            // TODO Auto-generated method stub
            try {
                  createDir(); //function to create html file with corresponding date
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Intent sender = new Intent(getApplicationContext(), webLoader.class);
            sender.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(sender);
            }
    }, durationOfMedi*1000);
 }
我基本上想做的是,我遍历每个媒体项,并根据它们的值等等。。我在IntentService中创建另一个html文件,然后尝试启动WebView活动以查看该html文件。每个媒体项目都有一些持续时间可以在屏幕上看到,这就是为什么我在第一个媒体之后使用PostDelay,并使用一些变量“计数器”来跟踪它。(对于第一个媒体,我直接创建文件并显示它,但之后我等待一段时间“durationOfMedi*1000”毫秒。)但在第一个媒体之后它就不起作用了。它只是通过html文件将该项目加载到屏幕上,然后就不会输入新的处理程序()。。。方法。
如果有人能帮助我,我将不胜感激。我对它一无所知。

我通过将当前线程直接休眠一段时间来实现这种情况,具体操作如下:

if(counter == 0){
    Thread.sleep(1000*previousDuration);
    createDir();
    Intent sender = new Intent(getApplicationContext(), webLoader.class);
    sender.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(sender);                                                      
}
通过应用这种方法,我可以启动其他活动。为了避免堆栈上的任务过多,我还包括:

android:noHistory = "true"

在我的清单文件中。成功了。如果有人遇到这种情况,我会发布这篇文章。

我通过将当前线程直接休眠一段时间来完成这种情况,具体操作如下:

if(counter == 0){
    Thread.sleep(1000*previousDuration);
    createDir();
    Intent sender = new Intent(getApplicationContext(), webLoader.class);
    sender.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(sender);                                                      
}
通过应用这种方法,我可以启动其他活动。为了避免堆栈上的任务过多,我还包括:

android:noHistory = "true"

在我的清单文件中。成功了。如果有人遇到这种情况,我会发布这篇文章。

如果需要更多信息,请询问。我还需要一个帮助=)。确定问题似乎来自handler.postdayed()。我试图直接激发WebView的第二个意图,它成功地用一个新的html启动了WebView。但我仍然需要等待一定的时间(即Medi*1000的持续时间)。欢迎提供任何帮助。ok仍然存在关于handler()的使用问题。postDelayed。不知道为什么,但它仍然不起作用。如果需要更多的信息,就去问吧。我还需要一个帮助=)。确定问题似乎来自handler.postdayed()。我试图直接激发WebView的第二个意图,它成功地用一个新的html启动了WebView。但我仍然需要等待一定的时间(即Medi*1000的持续时间)。欢迎提供任何帮助。ok仍然存在关于handler()的使用问题。postDelayed。不知道为什么,但它仍然不起作用。