I’m developing an app that we will put on Android tablets on be used by employees in the field. We want to lock down internet access as much as possible to minimize data usage (so that the employees can’t go streaming Netflix movies or something and driving up our data usage). As part of that effort, I’d like to have http(s)?:// links open up in a custom activity I made. Now, I can easily do that by registering the activity with an intent filter on the http/https schemas, but I’d prefer not to have the user have to choose between browsers when opening a link, and I don’t want my activity to become the default activity for every link (there may be situations in which the user should be using the Android browser).
Is there a way to set up my activity as the http handler…but only for links launched from my app?
If the links are from your app, just use
startActivity()with anIntentidentifying your activity, rather than some genericIntentlikeACTION_VIEW.If your issue is that you are displaying the Web content in a
WebViewand links clicked there lead to the browser, usesetWebViewClient()along with aWebViewClientimplementation that handlesshouldOverrideUrlLoading().