Saturday 26 November 2011

WML Support in Android

 WML or wap pages are built for older browser. Still wap pages available today but Android browser does not support it.
If you open it in a Android Browser it will be rendered as text. This is because in Android Framwork it's Mime Type is changed as text.

 Even though wml code is present in external/webkit/WebCore, it is not enabled in Build structure.

We can achieve this by following below steps.

Step 1: Change in Android Framework (webkit/LoadListener.java)

handleHeaders(Headers headers){...


else if (mMimeType.equals("text/vnd.wap.wml")) {
                // As we don't support wml, render it as plain text
                mMimeType = "text/plain";
 
 
changes it to
  
 else if (mMimeType.equals("text/vnd.wap.wml")) {
 mMimeType = "text/vnd.wap.wml";
}
 
Step 2: Set ENABLE(WML) to true
 
Step 3:  modification in .mk files

To build the wml in Android Some Generated files are needed.

Like

WMLNames.h, WMLNames.cpp, WMLAttributeNames.h, WMLAttributeNames.cpp

To Generate these files 

Android.mk
Android.derived.mk
Android.derived.jscbindings.mk
Android.jscbindings.mk                   needs to be modified

add 


GEN:= $(intermediates)/WMLNames.cpp $(intermediates)/WMLElementFactory.cpp
$(GEN): PRIVATE_PATH := $(LOCAL_PATH)
$(GEN): PRIVATE_CUSTOM_TOOL = perl -I $(PRIVATE_PATH)/bindings/scripts $< --tags $(wml_tags) --attrs $(wml_attrs)  --extraDefines "$(FEATURE_DEFINES)" --factory --wrapperFactory --output $(dir $@)
$(GEN): wml_tags := $(LOCAL_PATH)/wml/WMLTagNames.in
$(GEN): wml_attrs := $(LOCAL_PATH)/html/WMLAttributeNames.in
$(GEN): $(LOCAL_PATH)/dom/make_names.pl $(wml_tags) $(wml_attrs)
                $(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)

 in Android.derived.mk

 
 Once Those generated files are created your job is almost done.


Step 4: Remove error related to INSPECTOR


Once the build is finished webkit library is built and Android Browser now supports wml


Hope This will help..