0

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?

opc0de
  • 11,557
  • 14
  • 94
  • 187

3 Answers3

1

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>
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

Of course, you can get the current url:

URL url = new URL(mWebView.getUrl());
Sebastian Breit
  • 6,137
  • 1
  • 35
  • 53
0

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.

Community
  • 1
  • 1
Anirudh Ramanathan
  • 46,179
  • 22
  • 132
  • 191