Trouble getting WebView and anonymous BroadcastReceiver communicating in an Activity
<p>I want an anonymous BroadcastReceiver to respond to links inside of a WebView. I thought I could do this with intent-filters, but things are not working. Here is the code for my Activity:</p>

<pre><code>public class WebViewReceiverActivity extends Activity {

    private BroadcastReceiver mReceiver;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        WebView webView = (WebView) findViewById(R.id.webview);

        webView.loadData("&lt;a href=\"webview-receiver:///\"&gt;This should Toast&lt;/a&gt;", "text/html", "utf8");

        mReceiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                Uri data = intent.getData();
                if (data != null &amp;&amp; data.getScheme().equals("webview-receiver")) {
                    Toast.makeText(WebViewReceiverActivity.this, "Toasty", Toast.LENGTH_SHORT).show();
                }
            }

        };

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_VIEW);
        intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
        intentFilter.addCategory(Intent.CATEGORY_BROWSABLE);
        intentFilter.addDataScheme("webview-receiver");

        registerReceiver(mReceiver, intentFilter);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        unregisterReceiver(mReceiver);
    }


}
</code></pre>

<p>Here is the main.xml layout:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

    &lt;WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbarStyle="insideOverlay" /&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>When clicking the link in the WebView I get a page not found error and no Toast. Is this approach possible? I am thinking about just using WebViewClient and shouldOverrideUrlLoading() instead, but if I can get the BroadcastReceiver approach working than I would prefer that.</p>
