Hi All, I need to the following :- On the android browser menu click I need to fetch URL from a file, load them in a WebView, dump the Render Tree in some file. There can be any no of URLs present in the file.
I have done teh following:- Created a WebViewClient object, overriding onPageCompleted(). Then, called setWebViewClient() on WebView object to tie the WebViewClient to the WebView. Then, implemented onPageCompleted() to do the above mentioned task when the page is loaded. The above method works fine for a single URL but when I try to do the same with multiple URLs only last URL in loop is rendered completely and its Render Tree is generated. Could anyone please let me know what exactly the problem is. In BrowserActivity.java in onOptionsItemSelected() I have written code as follows:- case R.id.dump_rendertree_menu_id: myFunction(); break; ------- Function Definitions----------------------- public void myFunction() { TabControl.Tab dump_current_tab = mTabControl.getCurrentTab(); WebView dump_current_webview[] = new WebView[10]; WebView view = null; int count = 0, j = 0; final int webview_progress; BufferedWriter output = null; BufferedReader reader = null; File file = null; String temp_text_reader = null, url = null; String text_reader[] = new String[5]; String text_writer = "http://www.msn.com/\nhttp:// www.android.com/\nhttp://www.yahoo.co.in/\nhttp://www.google.com/\nhttp://www.w3schools.com/"; try { file = new File("/data/data/ com.android.browser/URL_new.txt"); output = new BufferedWriter(new FileWriter (file)); output.write(text_writer); System.out.println("Your file has been written"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (output != null) { output.close(); } } catch (IOException e) { e.printStackTrace(); } } try { reader = new BufferedReader(new FileReader (file)); System.out.println("\n The Reader is ready to read URL"); while ((temp_text_reader = reader.readLine()) ! = null) { text_reader[j] = temp_text_reader; System.out.println("\n The URL "+ temp_text_reader +" is copied in string array"); j++; count++; } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (reader != null) { reader.close(); } } catch (IOException e) { e.printStackTrace(); } } for(j = 0 ; j < count ; j++) { try { dump_current_webview[j] = dump_current_tab.getWebView(); System.out.println("\n The URL "+ text_reader[j] + " is about to load"); view = dump_current_webview[j]; url = text_reader[j]; view.loadUrl (url); mySecondFunction (view,url); } catch (Exception e) { e.printStackTrace(); } } } public void mySecondFunction(WebView view, String url) { WebViewClient myWebViewClient = new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { System.out.println("\n The URL "+ url +" from file is loaded"); view.getWebViewCore().nativeDumpRenderTree (true); System.out.println("\n The RT for the URL"+ url +" from file is generated"); } }; view.setWebViewClient(myWebViewClient); } Thanks, Neha -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en