Hi,
I've been working on this today and haven't managed to make it happen
yet.
I registered an intent-filter for an activity in my
AndroidManifest.xml like this:
<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="myapp/zzz" />
</intent-filter>
When I click a link from the browser to a ".zzz" file with a content-
type value "myapp/zzz" (I verified this by looking at the headers of
the server response) I get 2 kinds of errors:
1. A dialog box saying: "Error. Unable to download file as content
type is not supported"
the logcat trace for this is:
INFO/ActivityManager(518): Starting activity: Intent
{ action=android.intent.action.VIEW data=http://www.mysite.com/
myfile.zzz comp={com.google.android.browser/
com.google.android.browser.BrowserActivity} }
DEBUG/browser(3255): *-* Start browser instrument
VERBOSE/favicons(3255): Starting load with icon 0x0 for
http://www.mysite.com/myfile.zzz
DEBUG/(3255): removing file '/sdcard/download/myfile.zzz-part'
2. An uncaught exception displayed as a dialog box giving the "Unable
to add window" error. logcat trace is:
WARN/WindowManager(518): Attempted to add application window with
unknown token HistoryRecord{402d80b0 {com.google.android.browser/
com.google.android.browser.BrowserActivity}}. Aborting.
DEBUG/dalvikvm(3572): Exception Landroid/view/WindowManager
$BadTokenException; from ViewRoot.java:186 not caught locally
DEBUG/dalvikvm(3572): Exception Landroid/view/WindowManager
$BadTokenException; from ZygoteInit.java:1553 not caught locally
DEBUG/AndroidRuntime(3572): Shutting down VM
WARN/dalvikvm(3572): threadid=3: thread exiting with uncaught
exception (group=0x4000fdf8)
ERROR/AndroidRuntime(3572): Uncaught handler: thread Main exiting due
to uncaught exception
...
Apparently, the second error happens after I clear the browser cache,
and from that point I get the first error.
Seems like the intent for the mime type I specified is not found -
although I'm not sure.
Perhaps I should mention that I managed to get my activity fired by
registering a scheme in an intent filter using:
<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="zzz" />
</intent-filter>
but this means I need to handle the file download myself (not much of
a problem), but worse, that this is a very proprietary kind of URI
scheme that I think is good to avoid.
Any ideas?
Anyone managed to get their activities launched by the browser after
downloading a file using a mimeType intent-filter?
Thanks!
Amos.
P.S.
I'm using m5-rc15.
On Mar 27, 7:15 pm, "Jean-Baptiste Queru" <[EMAIL PROTECTED]> wrote:
> To be perfectly honest here, I'm not familiar with Java Web Start (I had
> never heard of it before), and therefore I'll have a hard time comparing
> it to the capabilities I'm working on. Because of that, and because it's
> not available yet, I'd rather not speculate on what might or might not
> happen.
>
> JBQ
>
> On Thu, Mar 27, 2008 at 7:32 AM, Anil <[EMAIL PROTECTED]> wrote:
>
> > Will you be developing something similar to Java Web Start for
> > distribution?
> > -
> > Anil
>
> > On Mar 26, 8:57 pm, "Jean-Baptiste Queru" <[EMAIL PROTECTED]> wrote:
> > > Hello, I'm the Google engineer who works on that area of Android.
>
> > > Indeed, the download system is still under development, and you can
> > expect
> > > to see changes there at some point.
>
> > > The two key aspects that you need to know is that:
> > > -the MIME type is what matters. The URI extension is not relevant in
> > this case.
> > > -in order for the files to be downloaded and for your app to be
> > launched, your
> > > application needs to register as a viewer the MIME type of your files
> > > (Intent.VIEW_ACTION).
>
> > > There's a high probability that in the long run the files downloaded
> > from the
> > > browser will be saved on the SD card (which the emulator can emulate).
> > > However, I am not sure what the exact behavior is in the currently
> > available
> > > SDKs.
>
> > > (For what it's worth, at the implementation level, there's indeed going
> > to be
> > > some code that involves some content providers and some permissions, but
> > > at your level you don't need to worry about that, that's only used by the
> > > browser to manage its downloads).
>
> > > JBQ
>
> > > On Wed, Mar 26, 2008 at 5:52 PM, hackbod <[EMAIL PROTECTED]> wrote:
>
> > > > This stuff is still under development, but I believe right now it is
> > > > downloaded into a content provider that anyone can access. In the
> > > > future, this will be downloaded to a more sophisticated download
> > > > manager, that maintains per-item permissions so only the application
> > > > requesting a download can access the files it is downloading, and it
> > > > can then allow other applications to access particular uris -- such as
> > > > when the user clicks on one of the downloads, granting the launched
> > > > activity permission to open that particular uri.
>
> > > > On Mar 26, 3:29 pm, Amos <[EMAIL PROTECTED]> wrote:
> > > > > Thanks for your reply, Dianne!
>
> > > > > I'll register my Activity like you specified.
>
> > > > > But how will I be able to access the downloaded file. Will it be
> > > > > downloaded to a temp location and have global read permission set on
> > > > > it? How will the file's path be passed to me using the Intent sent
> > by
> > > > > the browser?
>
> > > > > Many thanks,
>
> > > > > Amos
>
> > > > > On Mar 26, 7:02 pm, hackbod <[EMAIL PROTECTED]> wrote:
>
> > > > > > All of Android's file mappings are based on MIME types. As long
> > as
> > > > > > your web server is returning the correct MIME type, you can
> > implement
> > > > > > an activity that says it knows how to VIEW that MIME type and it
> > will
> > > > > > be launched when the user clicks on such a file after downloading
> > it.
>
> > > > > > On Mar 26, 3:34 am,Amos<[EMAIL PROTECTED]> wrote:
>
> > > > > > > Hi,
>
> > > > > > > I would like to implement the following scenario:
>
> > > > > > > When a user browses a web page withBrowserand clicks a link
> > with a
> > > > > > > special file extension (which is unique to my application, such
> > as
> > > > > > > "www.mysite.com/somefile.xxx"), that file will be downloaded
> > and then
> > > > > > > my application launched to view the downloaded file.
>
> > > > > > > I'd like thebrowserto handle the file download if possible, and
> > when
> > > > > > > it's done start one of my activities and provide the file to
> > it.
>
> > > > > > > This is desktop behavior and I'm not sure it conforms to the
> > Android
> > > > > > > intent/content provider way of doing things - but this is what
> > I'd
> > > > > > > like to happen.
>
> > > > > > > Any ideas or pointers?
>
> > > > > > > Thanks in advance,
>
> > > > > > >Amos
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---