当前位置: 动力学知识库 > 问答 > 编程问答 >

Extend browser functionality in Android

问题描述:

When I open the Android's default browser I want to add a button or a menu entry when it's clicked to open my Intent and pass me the current url parameter.

Is this possible in Android?

网友答案:

Only by means of the Share option, if the browser in question has one. The standard AOSP Browser app will have such a "Share" option in the action overflow. It triggers an ACTION_SEND Intent, with a MIME type of text/plain, so any activities claiming to support that in the manifest via an <intent-filter> will be able to respond:

        <intent-filter android:label="@string/app_name">
            <action android:name="android.intent.action.SEND"/>

            <data android:mimeType="text/plain"/>

            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
网友答案:

Of course, you can get the current url:

URL url = new URL(mWebView.getUrl());
网友答案:

I don't know if I understood this right, but I think this what you want.

When the user clicks your button, you can redirect to a custom url, somesite://current_page_url. using javascript or the addon's capability.

That can be picked up by your intent filter with host set to "somesite", as done here.

分享给朋友:
您可能感兴趣的文章:
随机阅读: