[android-developers] Re: Issues: Webview.loadData() trying to load a string created from a read file(asset) and a string

2008-11-25 Thread polo777

Hi,

Finally I created the content provider overriding the openFile method
so that I can use loadUrl() but still a part of the Javascript (of the
page loaded) that worked when it was loading from the web or an asset
file doesn't work here. I got a WebCore error telling me there is a
parsing issue!!! The content is exactly the same. Looks like the
WebKit doesn't work the same whether the file is an asset, page loaded
from Network or a string or a text from a file (ContentProvider
solution).
This problem drives me crazy!

Polo



On Nov 21, 4:56 pm, polo777 <[EMAIL PROTECTED]> wrote:
> I am gonna give a try and let you know. Thanks Mark!
>
> On Nov 21, 4:45 pm, Mark Murphy <[EMAIL PROTECTED]> wrote:
>
> > polo777 wrote:
> > > After having tried to use "addJavascriptInterface", I start working on
> > > the ContentProvider-based solution that you described.
> > > With this solution can I just create/open/read/delete a file in which
> > > I would store my string (javascript + html) so that I could use
> > > loadUrl or loadDataWithBaseURL properly using the url "content://
> > > blabla.provider"?
>
> > In theory, yes. I haven't tried it myself, though I should be giving
> > that a shot sometime next week, I think. I've seen other posts on these
> > lists that suggest others have it working, though it is not exactly trivial.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
>
> > Android Training on the Ranch! -- Mar 16-20, 
> > 2009http://www.bignerdranch.com/schedule.shtml
>
>
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Issues: Webview.loadData() trying to load a string created from a read file(asset) and a string

2008-11-21 Thread polo777

I am gonna give a try and let you know. Thanks Mark!


On Nov 21, 4:45 pm, Mark Murphy <[EMAIL PROTECTED]> wrote:
> polo777 wrote:
> > After having tried to use "addJavascriptInterface", I start working on
> > the ContentProvider-based solution that you described.
> > With this solution can I just create/open/read/delete a file in which
> > I would store my string (javascript + html) so that I could use
> > loadUrl or loadDataWithBaseURL properly using the url "content://
> > blabla.provider"?
>
> In theory, yes. I haven't tried it myself, though I should be giving
> that a shot sometime next week, I think. I've seen other posts on these
> lists that suggest others have it working, though it is not exactly trivial.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
>
> Android Training on the Ranch! -- Mar 16-20, 
> 2009http://www.bignerdranch.com/schedule.shtml
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Issues: Webview.loadData() trying to load a string created from a read file(asset) and a string

2008-11-21 Thread Mark Murphy

polo777 wrote:
> After having tried to use "addJavascriptInterface", I start working on
> the ContentProvider-based solution that you described.
> With this solution can I just create/open/read/delete a file in which
> I would store my string (javascript + html) so that I could use
> loadUrl or loadDataWithBaseURL properly using the url "content://
> blabla.provider"?

In theory, yes. I haven't tried it myself, though I should be giving 
that a shot sometime next week, I think. I've seen other posts on these 
lists that suggest others have it working, though it is not exactly trivial.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Issues: Webview.loadData() trying to load a string created from a read file(asset) and a string

2008-11-21 Thread polo777

Hi Mark,

First thanks a lot for your answers...

After having tried to use "addJavascriptInterface", I start working on
the ContentProvider-based solution that you described.
With this solution can I just create/open/read/delete a file in which
I would store my string (javascript + html) so that I could use
loadUrl or loadDataWithBaseURL properly using the url "content://
blabla.provider"?

I am not sure exactly how to proceed.

Thanks
Polo

On Nov 21, 4:26 pm, Mark Murphy <[EMAIL PROTECTED]> wrote:
> polo777 wrote:
> > Re,
>
> > Actually, I still have a problem.
> > When I use this trick, the javascript containing in my page doesn't
> > work whereas the same page(html/javascript) works when I load it from
> > the network or from a file:///android_asset/myfile.html.
>
> > Anything?
>
> Your simple options are:
>
> 1. Instead of your fake base URL, use a real network URL pointing to the
> spot where the Javascript, images, and other stuff lives. Of course,
> this will require a network connection to work. You may wish to also
> supply your WebView with a WebViewClient implementation, so you can hook
> shouldOverrideUrlLoading() to determine if a given clicked-upon link
> should go to the Internet or should be loaded from your
> locally-generated content.
>
> 2. Don't use WebView for locally-generated material.
>
> Your more complicated options include building a ContentProvider for
> serving your HTML, Javascript, and whatnot, and using the appropriate
> content: URL to load it.
>
> In general, Android makes it rather difficult for one to support
> locally-hosted Web content.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
>
> Android Training on the Ranch! -- Mar 16-20, 
> 2009http://www.bignerdranch.com/schedule.shtml
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Issues: Webview.loadData() trying to load a string created from a read file(asset) and a string

2008-11-21 Thread Mark Murphy

polo777 wrote:
> Re,
> 
> Actually, I still have a problem.
> When I use this trick, the javascript containing in my page doesn't
> work whereas the same page(html/javascript) works when I load it from
> the network or from a file:///android_asset/myfile.html.
> 
> Anything?

Your simple options are:

1. Instead of your fake base URL, use a real network URL pointing to the 
spot where the Javascript, images, and other stuff lives. Of course, 
this will require a network connection to work. You may wish to also 
supply your WebView with a WebViewClient implementation, so you can hook 
shouldOverrideUrlLoading() to determine if a given clicked-upon link 
should go to the Internet or should be loaded from your 
locally-generated content.

2. Don't use WebView for locally-generated material.

Your more complicated options include building a ContentProvider for 
serving your HTML, Javascript, and whatnot, and using the appropriate 
content: URL to load it.

In general, Android makes it rather difficult for one to support 
locally-hosted Web content.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Issues: Webview.loadData() trying to load a string created from a read file(asset) and a string

2008-11-21 Thread polo777

Re,

Actually, I still have a problem.
When I use this trick, the javascript containing in my page doesn't
work whereas the same page(html/javascript) works when I load it from
the network or from a file:///android_asset/myfile.html.

Anything?

Polo

On Nov 21, 1:06 pm, polo777 <[EMAIL PROTECTED]> wrote:
> Thanks a lot of Mark.
>
> This workaround did the trick.
>
>  String mimeType = "text/html";
>  String encoding = "utf-8";
>  mWebView.loadDataWithBaseURL("fake://fake.com", out.toString(),
> mimeType, encoding, null);
>
> Regards,
> Polo
>
> On Nov 21, 11:42 am, Mark Murphy <[EMAIL PROTECTED]> wrote:
>
> > polo777 wrote:
> > > Does someone have a solution? That would be great.
>
> > Use loadDataWithBaseURL(), even if you have to pass in a fake URL.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
>
> > Android Training on the Ranch! -- Mar 16-20, 
> > 2009http://www.bignerdranch.com/schedule.shtml
>
>
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Issues: Webview.loadData() trying to load a string created from a read file(asset) and a string

2008-11-21 Thread polo777

Thanks a lot of Mark.

This workaround did the trick.

 String mimeType = "text/html";
 String encoding = "utf-8";
 mWebView.loadDataWithBaseURL("fake://fake.com", out.toString(),
mimeType, encoding, null);

Regards,
Polo


On Nov 21, 11:42 am, Mark Murphy <[EMAIL PROTECTED]> wrote:
> polo777 wrote:
> > Does someone have a solution? That would be great.
>
> Use loadDataWithBaseURL(), even if you have to pass in a fake URL.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
>
> Android Training on the Ranch! -- Mar 16-20, 
> 2009http://www.bignerdranch.com/schedule.shtml
--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Issues: Webview.loadData() trying to load a string created from a read file(asset) and a string

2008-11-21 Thread Mark Murphy

polo777 wrote:
> Does someone have a solution? That would be great.

Use loadDataWithBaseURL(), even if you have to pass in a fake URL.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

--~--~-~--~~~---~--~~
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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---