WebView encoding? why?

by Angelo » Sat, 29 May 2010 06:55:13 GMT


Sponsored Links
 Hello all,

I have started to work with the WebView component of Android Platform,
but the API to load data to the component is confusing me, because it
includes a parameter with a encoding.

In both methods:
public void  loadData  (String data, String mimeType, String
encoding);
public void  loadDataWithBaseURL  (String baseUrl, String data, String
mimeType, String encoding, String historyUrl);

you have to specify an encoding. In both cases, the API documentation
says that is is the encodign of the data (data parameter).

Well, as  know, if you provide data as a String object, the String is
internally stored in UTF-16 (unicode). To get a String object from a
external source, you need to specify the external source encoding to
convert it to UTF-16 and get the String internal representation
(String(byte[] data, String encoding)). So, at this moment, when you
have an String instance, everything from the original source has been
converted to UTF-16.
So, why do you need to specify an encoding if you are providing the
data as a String object?

I don't know the internal implementation of WebKit, but let's suppose
that, WebKit has a method, to render a source, providing as content an
InputStream and a default encoding. Well, as I know, when you process
a HTML page, you use the default encoding to read the HTML characters,
and if you find a <meta> tag specifing a different encoding, from that
moment, you have to use the new encoding to decode the characters of
the HTML page.

But what happens if you supply a HTML page that contains this <meta>
tag:
<meta HTTP-EQUIV="content-type" CONTENT="text/html;
charset=ISO-8859-1"/>

using one of the methods specified at the top of this post,
how are you going to read ISO-8859-1 encoding from a String that it is
in UTF-16 encoding?
if the WebKit filtering this <meta> tags, and doesn't taking in
account the encoding specified in this tag?

Well, all of this is very confusing for me, because I don't understand
why the API includes this encoding parameter. I also don't know if the
<meta> encoding tags are filtered when the source is provided as a
String?

Can anyone solve my doubts?

Thanks in advance

--



WebView encoding? why?

by Frank Weiss » Sat, 29 May 2010 11:11:42 GMT


 I think your puzzlement is well justified. It would seem to make more sense
that the first parameter should be byte[] instead of String.

Without looking at the Android source, I have some hypothesis:

1. The loadUrl() method indicates mimeType may be "image/jpeg" and encoding
may be "base64". In this case it would be reasonable that although the first
parameter is String, the correct loading of the data would require knowing
the encoding (although I don't know what other encoding may be reasonable).
2. In the absence of the ContentType HTTP header, you need to specify the
second and third parameters, perhaps because the WebView methods delegate to
another class/method that does require them.
3. Perhaps the encoding parameter is entirely ignored in the case that the
mimeType is text/*. That's where looking at the source would be helpful.

--


Sponsored Links


Other Threads

1. touchscreen: getPressure and getSize should change as finger drags, yes?

This is a bug on the Droid software, that will be fixed in the future.
 (Actually it's my fault in some special touch filtering code that was put
into the framework for Droid. :p)




> website: 

2. Can't play any video on android 2.0 (AOSP)

Hi all, I'm porting the android AOSP(master branch) to my board.

My problem is : If I played any video, the system break down and
reboot ...

The "E/PV" error message was from OpenCore code.

 I didn't change any code about MediaPlayer and OpenCore. - -#

Kernel must be OK, I can play video on V1.6(donut) ROM use the same
kernel.

The following is the debug log :

////////////////////////////////////////////////////

I/ActivityManager(  795): Displayed activity
org.iii.romulus.meridian/.VideoPlayActivity: 6093 ms (total 6093 ms)
W/PlayerDriver(  780): Using generic video MIO
E/PV      (  780): PVLOG:TID
(0x42b20):Time=824:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=0, samplesize=1108, TS=5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=826:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=1, samplesize=875, TS=15
E/PV      (  780): PVLOG:TID
(0x42b20):Time=829:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=2, samplesize=1089, TS=5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=832:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=3, samplesize=1009, TS=5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=863:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=4, samplesize=1215, TS=5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=864:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=5, samplesize=1472, TS=5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=866:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=6, samplesize=2061, TS=5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=875:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=7, samplesize=1601, TS=5
W/MediaPlayer( 1014): info/warning (1, 44)
I/MediaPlayer( 1014): Info (1,44)
E/PV      (  780): PVLOG:TID
(0x42b20):Time=897:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=8, samplesize=1916, TS=5
D/MediaPlayer( 1014): getMetadata
E/PV      (  780): PVLOG:TID
(0x42b20):Time=930:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=9, samplesize=2312, TS=5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=960:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=10, samplesize=2349, TS5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=971:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=11, samplesize=1921, TS5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=992:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=12, samplesize=2063, TS5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1004:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=13, samplesize=1923, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1010:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=14, samplesize=2194, T5
D/ALSAModule(  780): open called for devices 00000002 in mode 0...
I/ALSAModule(  780): Initialized ALSA PLAYBACK device
AndroidPlayback_Speaker_normal
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1156:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=15, samplesize=2215, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1232:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=16, samplesize=1108, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1234:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=17, samplesize=875, TS5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1236:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=18, samplesize=1089, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1237:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=19, samplesize=1009, T5
W/MediaPlayer( 1014): info/warning (1, 44)
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1276:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=20, samplesize=1215, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1295:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=21, samplesize=1472, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1334:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=22, samplesize=2061, T5
I/MediaPlayer( 1014): Info (1,44)
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1437:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=23, samplesize=1601, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1489:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=24, samplesize=1916, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=1516:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=25, samplesize=2312, T5

...

E/PV      (  780): PVLOG:TID
(0x42b20):Time=2243:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=35, samplesize=1954, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2426:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 0
E/gralloc (  795): invalid gralloc handle (at 0x0)
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2456:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=36, samplesize=2237, T5
I/DEBUG   (  777): *** *** *** *** *** *** *** *** *** *** *** *** ***
*** *** ***
I/DEBUG   (  777): Build fingerprint: 'Qdroid/smartq/smartq/:AOSP/
MASTER/eng.special.20091212.184507:eng/test-keys'
I/DEBUG   (  777): pid: 795, tid: 807  >>> system_server <<<
I/DEBUG   (  777): signal 11 (SIGSEGV), fault addr e1832fdb
I/DEBUG   (  777):  r0 0011f650  r1 ac141498  r2 41092b90  r3 00000001
I/DEBUG   (  777):  r4 0011f650  r5 00000005  r6 00000000  r7 e1832fcf
I/DEBUG   (  777):  r8 44dc7d88  r9 44cc788c  10 44cc7874  fp 0013ba28
I/DEBUG   (  777):  ip ad36bbe0  sp 44dc7d50  lr ac0638f4  pc
ac066194  cpsr 20000010
I/DEBUG   (  777):          #00  pc 00066194  /system/lib/libskia.so
I/DEBUG   (  777):          #01  lr ac0638f4  /system/lib/libskia.so
I/DEBUG   (  777):
I/DEBUG   (  777): code around pc:
I/DEBUG   (  777): ac066184 e92d41f0 e590701c e3a06000 e3a03001
I/DEBUG   (  777): ac066194 e597800c e5974010 e24dd008 e1580006
I/DEBUG   (  777): ac0661a4 e1a05000 e5c030bc e5c030a8 e5876010
I/DEBUG   (  777):
I/DEBUG   (  777): code around lr:
I/DEBUG   (  777): ac0638e4 e1a00004 e5941000 e1a0e00f e591f01c
I/DEBUG   (  777): ac0638f4 e5940018 e1500005 cafffff8 e8bd8070
I/DEBUG   (  777): ac063904 e590301c e5930004 e12fff1e e590301c
I/DEBUG   (  777):
I/DEBUG   (  777): stack:
I/DEBUG   (  777):     44dc7d10  00000001
I/DEBUG   (  777):     44dc7d14  00000007
I/DEBUG   (  777):     44dc7d18  41092b90  /dev/ashmem/dalvik-
LinearAlloc (deleted)
I/DEBUG   (  777):     44dc7d1c  ad040a41  /system/lib/libdvm.so
I/DEBUG   (  777):     44dc7d20  0011f650  [heap]
I/DEBUG   (  777):     44dc7d24  0013ba28  [heap]
I/DEBUG   (  777):     44dc7d28  43800b38  /dev/ashmem/mspace/dalvik-
heap/2 (deleted)
I/DEBUG   (  777):     44dc7d2c  ad037b5d  /system/lib/libdvm.so
I/DEBUG   (  777):     44dc7d30  ad037b41  /system/lib/libdvm.so
I/DEBUG   (  777):     44dc7d34  001158c0  [heap]
I/DEBUG   (  777):     44dc7d38  43800b38  /dev/ashmem/mspace/dalvik-
heap/2 (deleted)
I/DEBUG   (  777):     44dc7d3c  ad02900f  /system/lib/libdvm.so
I/DEBUG   (  777):     44dc7d40  0011f658  [heap]
I/DEBUG   (  777):     44dc7d44  ac066244  /system/lib/libskia.so
I/DEBUG   (  777):     44dc7d48  df002777
I/DEBUG   (  777):     44dc7d4c  e3a070ad
I/DEBUG   (  777): #00 44dc7d50  0011f650  [heap]
I/DEBUG   (  777):     44dc7d54  00000005
I/DEBUG   (  777):     44dc7d58  00000005
I/DEBUG   (  777):     44dc7d5c  44cc7894
I/DEBUG   (  777):     44dc7d60  44dc7d88
I/DEBUG   (  777):     44dc7d64  ac0638f4  /system/lib/libskia.so
I/DEBUG   (  777):     44dc7d68  ad36b040  /system/lib/
libandroid_runtime.so
I/DEBUG   (  777):     44dc7d6c  001158c0  [heap]
I/DEBUG   (  777):     44dc7d70  00000005
I/DEBUG   (  777):     44dc7d74  ad3434ef  /system/lib/
libandroid_runtime.so
I/DEBUG   (  777):     44dc7d78  44dc7da8
I/DEBUG   (  777):     44dc7d7c  00000000
I/DEBUG   (  777):     44dc7d80  42283bae  /data/dalvik-cache/
sys...@framework@framework....@classes.dex
I/DEBUG   (  777):     44dc7d84  ad00f1f8  /system/lib/libdvm.so
I/DEBUG   (  777):     44dc7d88  41094468  /dev/ashmem/dalvik-
LinearAlloc (deleted)
I/DEBUG   (  777):     44dc7d8c  0013ba28  [heap]
I/DEBUG   (  777):     44dc7d90  42283bae  /data/dalvik-cache/
sys...@framework@framework....@classes.dex
I/DEBUG   (  777):     44dc7d94  44dc7e38
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2610:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 1
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2634:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=37, samplesize=1869, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2786:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 2
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2806:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=38, samplesize=1558, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2830:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=39, samplesize=1751, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2868:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 3
E/PV      (  780): PVLOG:TID
(0x42b20):Time=2954:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 4

...

E/PV      (  780): PVLOG:TID
(0x42b20):Time=6097:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 42
E/PV      (  780): PVLOG:TID
(0x42b20):Time=6158:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=56, samplesize=2322, T5
E/PV      (  780): PVLOG:TID
(0x42b20):Time=6273:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 43
I/DEBUG   (  777): de{*filter*}d committing suicide to free the zombie!
binder: 795: binder_alloc_buf failed to map pages in userspace, no vma
binder: 780:1030 transaction failed 29201, size48-0
I/DEBUG   ( 1038): de{*filter*}d: Dec  6 2009 11:49:13
E/PV      (  780): PVLOG:TID
(0x42b20):Time=6332:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 44
E/PV      (  780): PVLOG:TID
(0x42b20):Time=6352:PVMFMP4FFParserNode::GenerateAACFrameFrags -
SeqNum=57, samplesize=2323, T5
binder: release proc 795, transaction 6357, not freed
binder: release proc 795, transaction 6358, not freed
binder: release proc 795, transaction 6359, not freed

...

binder: release proc 795, transaction 6398, not freed
binder: release proc 795, transaction 6399, not freed
I/ActivityThread( 1014): Removing dead content provider: settings
I/ActivityThread(  923): Removing dead content provider: settings
I/Activitybinder: 780:1030 transaction failed 29189, size48-0
Thread(  936): Removing dead content provider: settings
I/ActivityThread(  850): Removing dead content provider: settings
I/ActivityThread(  854): Removing dead content provider: settings
E/PV      (  780): PVLOG:TID
(0x42b20):Time=6469:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 45
I/ServiceManager(  775): service 'activity.providers' died
I/ServiceManager(  775): service 'account' died
I/ServiceManager(  775): service 'backup' died
I/ServiceManager(  775): service 'package' died
I/ServiceManager(  775): service 'activity.broadcasts' died
I/ServiceManager(  775): service 'activity.services' died
I/ServiceManager(  775): service 'meminfo' died
I/ServiceManager(  775): service 'permission' died
I/ServiceManager(  775): service 'telephony.registry' died
I/ServiceManager(  775): service 'activity' died
I/ServiceManager(  775): service 'usagestats' died
I/ServiceManager(  775): service 'cpuinfo' died
I/ServiceManager(  775): service 'activity.senders' died
I/ServiceManager(  775): service 'SurfaceFlinger' died
I/ServiceManager(  775): service 'power' died
I/request_suspend_state: wakeup (0->0) at 301198498002 (2009-12-18
21:07:28.063089000 UTC)
ServiceManager(  775): service 'batteryinfo' died
I/ServiceManager(  775): service 'entropy' died
I/ServiceManager(  775): service 'content' died
I/ServiceManager(  775): service 'clipboard' died
I/ServiceManager(  775): service 'hardware' died
I/ServiceManager(  775): service 'battery' died
I/ServiceManager(  775): service 'alarm' died
I/ServiceManager(  775): service 'sensor' died
I/ServiceManager(  775): service 'window' died
I/ServiceManager(  775): service 'bluetooth' died
I/ServiceManager(  775): service 'bluetooth_a2dp' died
I/ServiceManager(  775): service 'statusbar' died
I/ServiceManager(  775): service 'netstat' died
I/ServiceManager(  775): service 'input_method' died
I/ServiceManager(init: untracked pid 780 exited
init: untracked pid 850 exited
  775): service 'appwidget' died
I/ServiceManager(  775): service 'wifi' died
I/ServiceManagerinit: untracked pid 854 exited
init: untracked pid 864 exited
init: untracked pid 878 exited
init: untracked pid 893 exited
init: untracked pid 903 exited
init: untracked pid 913 exited
(  775): service 'connectivity' died
I/ServiceMinit: untracked pid 923 exited
init: untracked pid 936 exited
init: untracked pid 947 exited
anager(  775): service 'devicestoragemonitor' diinit: untracked pid
954 exited
init: untracked pid 964 exited
init: untracked pid 975 exited
ed
I/ServiceManager(  775): service 'accessibilinit: untracked pid 983
exited
init: untracked pid 994 exited
init: untracked pid 1014 exited
ity' died
I/ServiceManager(  775): service 'location' died
I/ServiceManager(  775): service 'notification' died
I/ServiceManager(  775): service 'mount' died
I/ServiceManager(  775): service 'search' died
I/ServiceManager(  775): service 'audio' died
I/ServiceManager(  775): service 'checkin' died
I/ServiceManager(  775): service 'wallpaper' died
I/ActivityThread(  878): Removing dead content provider: settings
E/PV      (  780): PVLOG:TID
(0x42b20):Time=6485:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 46
E/PV      (  780): PVLOG:TID
(0x42b20):Time=6493:AndroidSurfaceOutput::writeAsync: Playback
Progress - frame 47
E/vold    (  776): Framework disconnected
D/Zygote  (  779): Process 795 terminated by signal (11)
I/Zygote  (  779): Exit zygote because system server (795) has
terminated
E/installd(  782): eof
E/installd(  782): failed to read size
I/installd(  782): closing connection

******* Then android reboot ...

I'm googling about this, but no one have the same problem.

Can anybody help me out of this?

Thanks!!!

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website:  http://www.***.com/ 

3. Memory optimizations

4. super free register

5. Access menu layout and structure

6. video calling

7. My launcher can not launch ,why ?