Skip to content Skip to sidebar Skip to footer

How To Block Url To Open My Android App?

My android app allows to open other website like 'http://www.google.com' in a web browser from app. And my code is below.

Solution 1:

You can't avoid that, unless you specifically know what browser the user wants to use. And you don't know that.

You could have a WebView activity/fragment bundled in your application that will display webpages for you. That way you'd have full control. Here's a guide on WebView

Solution 2:

Your app is being displayed in the Complete Action Using chooser because of your intent-filter:

<intent-filter><categoryandroid:name="android.intent.category.DEFAULT" /><actionandroid:name="android.intent.action.VIEW" /><dataandroid:scheme="http" /><dataandroid:scheme="https" /></intent-filter>

and particularly because you've specified just a "scheme" entry, with no specific "host". This would in effect offer any web URL intent to open in your app.

Without understanding what your intended behavior exactly is, you can delete the <data> nodes from your intent-filter to remove your app from the Chooser.

Or alternatively, you might want specific URL's to offer your app in the Chooser, like http://yourserver.com and https://yourserver.com, for this you could alter your intent-filter as follows:

<data android:scheme="http" android:host="yourserver.com" />

Solution 3:

If your question is to block URLs of other websites in your android app for download purpose then search for the iConstants.java file in your project and write the following code:

publicinterfaceiConstants{
    publicstaticfinalString[] DISABLE_DOWNLOADING = {"URL", };
    publicstaticfinalString WEB_DISABLE = "We cannot allow to download videos form this website.";

}

Post a Comment for "How To Block Url To Open My Android App?"