How to catch / listen to Android web browser loading

I have an Android app that listens for browser intent to catch when a user clicks on a specific type of URI. In particular, I want my application to open when a user clicks on a hyperlink pointing to a torrent file (ig http: //somewhere/file.torrent ).

See below my intent filters from my AndroidManifest.xml application:

<intent-filter > <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:mimeType="application/x-bittorrent" android:scheme="http" /> </intent-filter> <intent-filter > <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="*" android:pathPattern=".*\\.torrent" android:scheme="http" /> </intent-filter> 

This works well as long as the hyperlink indicates the location of the file. BUT - sometimes the URLs directly point to the file and are interpreted by the server to return the file to be downloaded based on some identifier like this link http://www.mininova.org/get/13202308 , which returns the file back. In this case, my intent filters do not work, and the Android browser downloads the file instead of opening my application and transferring the intent from the file URI.

Does anyone know how to get a file URI?

thanks

+4
source share
1 answer

It is possible that in those cases, the HTTP response has a Content-disposition: header Content-disposition: like attachment;filename=file.torrent

If possible, the browser does not give up.

+1
source

Source: https://habr.com/ru/post/1389703/


All Articles