Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13059] Android: WebView: remove requirement to set baseURL

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionFixed
Resolution Date2013-03-14T03:48:09.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.1.0
ComponentsAndroid
Labelsandroid, qe-port, regression, webview
ReporterBanzai Mobile
AssigneeIngo Muschenetz
Created2013-02-13T17:50:03.000+0000
Updated2013-03-14T09:21:15.000+0000

Description

The following works on SDK 2.x and 3.0.0 on all platforms and on 3.0.2RC on iOS, but not on 3.0.2RC on Android:
Ti.UI.setBackgroundColor('#000');
var win = Ti.UI.createWindow();

var wv = Ti.UI.createWebView({
	html: '<p>This is an accented e character: è</p><img width="30" height="30" src="images/img.png" />'
});

win.add(wv);
win.open();
The defects are: 1) the accented character displays as garbage 2) the local image does not show at all (changing its path to "/images/img.png" does not work either)

Comments

  1. Banzai Mobile 2013-02-20

    I think this bug has not been given enough attention. Encoding issue can be solved by adding mimeType to a setHtml call, but I cannot find any way to show local images. IMHO, it is a showstopper and should have blocked release of 3.0.2GA Could somebody please at least find and publish a workaround for displaying local images in a webview on Android?
  2. Ingo Muschenetz 2013-02-20

    @Banzai--can you see if adding a baseURL solves the issues with images? See the related ticket TIMOB-9593.
  3. Banzai Mobile 2013-02-20

    @Ingo: Yes, setting the baseURL solves both problems (image and text encoding). That's good, because now calling setHtml with BOTH baseURL AND mimeType makes the html appear as code instead of rendered.
  4. Ingo Muschenetz 2013-02-20

    @Banzai. Great. So this was a change...where do you think the best place to advertise this is? Where would you have expected to find a note about this (and didn't)?
  5. Banzai Mobile 2013-02-20

    @Ingo: I'd mention it in the API docs for WebView, specifically under the html property and setHtml method. And of course in its own paragraph in the 3.0.2 release notes.
  6. Nathan Nadeau 2013-02-21

    Yes this would be nice to be mentioned in the API docs, the 3.0.2 release notes, and also the WebView user guide page: http://docs.appcelerator.com/titanium/3.0/#!/guide/The_WebView_Component-section-29004918_TheWebViewComponent-UsingLocalWebContentwithWebView. Note I have added an informational post to the Q&A forums: http://developer.appcelerator.com/question/148638/notice-titanium-302-android-webview-not-loading-local-resource-files-properly-via-html-property
  7. Olga Romero 2013-03-13

    I reproduced this issue with 3.0.2.GA Defects ARE GONE with: Titanium Studio, build: 3.0.3.201302201202 Titanium SDK, build: 3.1.0.v20130312161655 Device: Nexus7 Android version: 4.2
  8. Ingo Muschenetz 2013-03-14

    This was fixed as a result of re-fixing TIMOB-9593.
  9. Shyam Bhadauria 2013-03-14

    The local image is being shown now. Environment used for verification - Titanium SDK: 3.1.0.v20130311192922 Titanium  Studio:3.0.2.201302151605 Device: Nexus 7 Android 4.1

JSON Source