0

I am trying to act on downloading of a .XM file using the following link.

http://api.modarchive.org/downloads.php?moduleid=50479#ngs_cvrg.xm 

Here is a snippet from my manifest:

<application <activity ... <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.EDIT" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="application/octet-stream" /> <data android:host="*" /> <data android:pathPattern=".*\\.xm" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.EDIT" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="application/mytestapp" /> <data android:host="*" /> <data android:pathPattern=".*\\.xm" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="file" /> <data android:pathPattern=".*\\.xm" /> <data android:host="*" /> <data android:mimeType="text/plain"/> </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:scheme="http" /> <data android:mimeType="*/*" /> <data android:pathPattern=".*\\.xm" /> <data android:host="*" /> </intent-filter> </activity> 

Below is a snippet of my code which is not being called:

 @Override protected void onCreate( Bundle savedInstanceState ) { CheckForBrowserActivation(); } public void CheckForBrowserActivation() { Intent intent = getIntent(); String sData = intent.getDataString(); ContextActivity.LogDebugf( "Intent [%s] Data[%s]\n", intent.getAction(), sData ); if( Intent.ACTION_VIEW.equals( intent.getAction() ) ) { ContextActivity.LogDebugf( "BROWSER, ACTION_VIEW\n" ); 

Can somebody please tell me why the Intent filter is not working for this link?

I have successfully had the same code and type of intent filter working for m3u playlists etc.

UPDATE:

I'm trying to receive any application/octet-stream links now and I just cannot get my app to receive these intents with that link. I have tried both "http" and "file" schemes but neither work. I have removed all intent filters so I now only have one (see below). Why won't this work?

<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:scheme="http" /> <data android:host="*" /> <data android:mimeType="application/octet-stream" /> </intent-filter> 

1 Answer 1

1
http://api.modarchive.org/downloads.php?moduleid=50479#ngs_cvrg.xm 

The file extension of this URL is .php.

<data android:pathPattern=".*\\.xm" /> 

The file extension of this pathPattern is .xm. This does not match your URL.

Sign up to request clarification or add additional context in comments.

9 Comments

Thanks. Does that mean I should be filtering all .php URLs within my application and then looking for .xm within the full URL?
@SparkyNZ: Well, that will work, for http and https schemes. However, users may get confused, trying to determine why you are claiming to handle all PHP pages. Unfortunately, your test URL does not serve a distinct MIME type for this request, which basically means that all your options suck.
Surely there must be another way of intercepting the download of a .XM file? This was really easy to do with iOS. On the iPhone, I registered the XM file type and this link triggered an openURL method. I just want to achieve the same result on Android.
@SparkyNZ: Android focuses on MIME types. If you have content that has a distinct MIME type, and the server serves it with that MIME type, supporting that MIME type is easy.
@SparkyNZ: I dumped the HTTP headers using curl. It returns application/octet-stream, IIRC, which is a MIME type, but not a distinct MIME type. application/octet-stream is the ¯\_(ツ)_/¯ of MIME types. "Perhaps you could also suggest an example link that does return a MIME type too?" -- I would expect that the URL for this Web page returns text/html.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.