You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "胡争辉 (JIRA)" <ji...@apache.org> on 2013/06/27 04:40:19 UTC

[jira] [Created] (CB-4024) About url-filter Feature

胡争辉 created CB-4024:
-----------------------

             Summary: About url-filter Feature
                 Key: CB-4024
                 URL: https://issues.apache.org/jira/browse/CB-4024
             Project: Apache Cordova
          Issue Type: Wish
          Components: Android, Plugman
    Affects Versions: 2.8.0
            Reporter: 胡争辉
            Assignee: Joe Bowser
            Priority: Trivial


I noticed there is a comment in framework/src/org/apache/cordova/api/PluginManager.java Line 131 :

// What is this?

https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=blob;f=framework/src/org/apache/cordova/api/PluginManager.java;h=0a42b3abd2fc9c684728dbbdeb0cc62cd335c2b3;hb=HEAD#l131

So I review the relative code. After a few hour, I find this code works:

In config.xml

    <feature name="UrlFilter">
        <param name="android-package" value="com.daonao.test4.UrlFilter"/>
        <url-filter value="file:///android_asset/www/"/>
    </feature>

In class com.daonao.test4.UrlFilter

@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public WebResourceResponse shouldInterceptRequest(String url) {
ByteArrayInputStream stream = new ByteArrayInputStream(url.getBytes());
return new WebResourceResponse("text/plain", "UTF-8", stream);
}

I am not sure these code is the right way, but it works now for me.
For your information.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira