创建自定义 android 浏览器,打开其他应用请求的 url

create a custom android browser that open a url that other apps request

我想编写一个简单的自定义 Android 浏览器,例如 FirefoxChrome 浏览器,当其他应用程序选择我的自定义时可以打开特定的 URL浏览器。例如,一个邮件应用程序想要通过共享打开一个 URL,然后用户选择我的自定义浏览器。或者另一个 android 应用运行这个:

String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW); 
i.setData(Uri.parse(url)); startActivity(i); 

但是我的自定义浏览器如何获取从其他应用程序传递的 URL

您的问题不是很清楚,但是如果您谈论的是处理从其他应用程序发送的意图以打开 URL 在 webview 中 this 关于 android 开发人员培训的教程解释得很好。

我终于找到了使用 Intent 过滤器解决此问题的方法:

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <data android:scheme="http" />
            <data android:scheme="https" />
        </intent-filter>