| From | Sent On | Attachments |
|---|---|---|
| Peli | Aug 19, 2008 12:37 am | |
| Megha Joshi | Aug 19, 2008 11:35 am | |
| luca...@gmail.com | Aug 20, 2008 4:33 pm | |
| Megha Joshi | Aug 20, 2008 4:45 pm | |
| luca...@gmail.com | Aug 20, 2008 4:50 pm | |
| Gil | Aug 20, 2008 5:15 pm | |
| luca...@gmail.com | Aug 20, 2008 5:49 pm | |
| Gil | Aug 20, 2008 6:34 pm | |
| luca...@gmail.com | Aug 21, 2008 3:07 am | |
| Megha Joshi | Aug 21, 2008 1:20 pm | |
| luca...@gmail.com | Aug 22, 2008 4:46 am | |
| Megha Joshi | Aug 23, 2008 3:06 pm | |
| luca...@gmail.com | Aug 24, 2008 3:49 am | |
| handschuh | Aug 24, 2008 4:50 pm | |
| luca...@gmail.com | Aug 24, 2008 6:20 pm | |
| luca...@gmail.com | Sep 7, 2008 7:38 am | |
| friedger | Sep 8, 2008 6:01 am | |
| Megha Joshi | Sep 8, 2008 12:53 pm | |
| luca...@gmail.com | Sep 9, 2008 2:02 am | |
| Megha Joshi | Sep 9, 2008 11:09 am | |
| luca...@gmail.com | Sep 9, 2008 6:57 pm | |
| luca...@gmail.com | Sep 9, 2008 8:45 pm | |
| friedger | Sep 10, 2008 12:56 am | |
| Anthony | Oct 16, 2008 10:27 am | |
| Megha Joshi | Sep 8, 2009 4:12 pm | |
| Jason Proctor | Sep 8, 2009 4:18 pm | |
| Jayesh | Sep 16, 2009 12:19 pm | |
| plafayette | Oct 1, 2009 2:29 pm |
| Subject: | [android-developers] Re: How to display a local file in the browser? | |
|---|---|---|
| From: | handschuh (in...@shandschuh.de) | |
| Date: | Aug 24, 2008 4:50:54 pm | |
| List: | com.googlegroups.android-developers | |
Why does this limit exists?
If one wants to display html-code that has been fetched to view ONCE, this html-code has to be written in a content provider?
On Aug 24, 12:49 pm, "luca...@gmail.com" <luca...@gmail.com> wrote:
So, creating a content provider, which returns the same content of the file, would be accessed by loadUrl from webview, without any "url filtering"? Such as, for example... content://my.mailclient/231 Should retrieve the content of file "231.html": content provider acts as "webserver". Is it right?
On 24 Ago, 00:07, "Megha Joshi" <mjo...@google.com> wrote:
In that case you should use the content provider option mentioned earlier...Using a content provider would allow images as the content provider would be used for image loading too. Another alternative is to put the image inline, using the data:// scheme.
On Fri, Aug 22, 2008 at 4:47 AM, luca...@gmail.com <
luca...@gmail.com> wrote:
I already done that but there's another limit: data rendered via loadData arenotable to load remote resources (<img src="http://...">).
If you want the link to be loaded in your activity, you should provide a WebViewClient and implement shouldOverrideUrlLoading with { return
false; }
This option doesnotwork anymore, sorry for the confusion!
So the only way to load local file contents into WebView, is as Gil pointed out ...by loading the contents with loadData()/
Sample code: static final int MAXFILESIZE = 8096; String path = uri.getPath(); File f = new File(path); final long length = f.length(); if (!f.exists() || length > MAXFILESIZE) { return; }
// typecast to int is safe as long as MAXFILESIZE < MAXINT byte[] array = new byte[(int)length];
try { InputStream is = new FileInputStream(f); is.read(array); is.close(); } catch (FileNotFoundException ex) { // Checked for file existance already, so this shouldnot happen return; } catch (IOException ex) { // read or close failed Log.e(LOGTAG, "Failed to access file: " + path, ex); return; } mWebView.loadData(new String(array), mimeType, null);
There is a 8KB limit on the file size. So if your data is more that 8KB, you should create a content provider for your files and then the use the ContentResolver.openContentURI()...
I used WebView to display rich content emails (I'm writing a mail client). It worked well loading URI such as file://sdcard/filewhateveryouwant.xxx ... Now I upgraded to 0.9 and Android OS is displaying me apagewith "The requested file wasnotfound."
Maybe a PERMISSION issue?
On 19 Ago, 20:36, "Megha Joshi" <mjo...@google.com> wrote:
Browser doesnotsupport viewing local files...
On Tue, Aug 19, 2008 at 12:38 AM, Peli <peli...@googlemail.com>
wrote:
Is it possible to open a local file in the browser?
In the Android browser, I tried menu / go to: file:///sdcard/test.html
I always receive the error message: "Webpagenotavailable. Thewebpageat file:///sdcard/test.html couldnotbe loaded as: The requested file wasnotfound."
even though the files exist in /sdcard/test.html. Do I have to use a different URL, or put files into a different folder?
Peli
PS: From within an application, there seems to be a way to load local files:
"The prefix "file:///android_asset/" will cause WebView to load content from the current application's assets folder."
--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to andr...@googlegroups.com To unsubscribe from this group, send email to andr...@googlegroups.com Announcing the new Android 0.9 SDK beta! http://android-developers.blogspot.com/2008/08/announcing-beta-release-of-android-sdk.html For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---





