简体   繁体   中英

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

I want to write a simple custom Android browser, like the Firefox and Chrome browsers that can be open a specific URL when other app choose my custom browser. For example, a mail app want to open a URL by sharing and then the user choose my custom browser. Or another android app runs this:

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

But how do my custom browser get the URL that passed from the other application?

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

I finally found a solution for this using intent filter:

        <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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM