0
点赞
收藏
分享

微信扫一扫

截获浏览器的连接


1.截获自己的浏览器中的连接

private class MyWebViewClient extends WebViewClient { 
    @Override 
    public boolean shouldOverrideUrlLoading(WebView view, String url) { 
        setUrlparams(url); 
 
        if (url.indexOf("pattern") != -1) { 
            // do something 
            return false; 
        } else { 
            view.loadUrl(url); 
        } 
 
        return true; 
    } 
 
}

2. 截获自带浏览器的连接

<activity          android:name=".PhotostreamActivity" 
        android:label="@string/application_name"> 
 
        <!-- ... -->             
 
        <intent-filter> 
            <action android:name="android.intent.action.VIEW" /> 
            <category android:name="android.intent.category.DEFAULT" /> 
            <category android:name="android.intent.category.BROWSABLE" /> 
            <data android:scheme="http" 
                  android:host="flickr.com" 
                  android:pathPrefix="/photos/" /> 
            <data android:scheme="http" 
                  android:host="www.flickr.com" 
                  android:pathPrefix="/photos/" /> 
        </intent-filter> 
    </activity> 
final Intent intent = getIntent(); 
    final String action = intent.getAction(); 
 
    if (Intent.ACTION_VIEW.equals(action)) { 
        final List<String> segments = intent.getData().getPathSegments(); 
        if (segments.size() > 1) { 
            mUsername = segments.get(1); 
        } 
    }

该方法要注意检查vapi是否已经发生变化

举报

相关推荐

0 条评论