tags:

views:

214

answers:

2

I want my app to catch downloads of a particular kind of file. Here's the corresponding part of AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

     <activity android:name=".activity.ExeReceiver">
      <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:pathPattern=".*\\.exe" />
      </intent-filter>
     </activity>

Now, open a page with a link to an .exe file, click it. The download manager starts and then tells that The content is not supported on the phone. My activity doesn't even get called.

The questions are:

1) Why doesn't my activity get called?

2) What's the correct way of letting download manager do it's job and then get notified upon file download completion?

TIA.

+1  A: 

As a test, try replacing the wildcard in <data android:host="*" /> with:

  • A real wildcard (".*"), or
  • The actual server name you are testing against, or
  • Removing that whole <data android:host="*" /> element

If the actual server name works and the wildcards do not, that makes sense, insofar as the documentation does not say you can use wildcards for android:host. If removing the whole element then fails, though, I am not sure how you can catch files from arbitrary hosts. Hopefully, the first or third bullets will solve your problem.

CommonsWare
Thanks. Now that I've figured it out, I can tell that 1 won't work.
alex
+2  A: 

Turns out the

<data android:mimeType="*/*"/>

part is required. According to http://groups.google.com/group/android-developers/browse_thread/thread/521739d6b7082056 the file has to be downloaded manually (Uri: getIntent().getData()).

alex