Thursday, November 3, 2011

[android-developers] Android browser gets stuck when downloading files

I have this very specific request that I need to implement. We are
working on an application that lets users attach several different
type of files (pdf, jpg, png, doc, txt, etc). I need to be able to
download the file using Android's default browser.

Here's the problem I have: the URL I get from the server is usually
like this: https://server:port/notes/attachment/91 and if I do:

`Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url.toString()));
mContext.startActivity(i);`
Then, after the user authenticates the download seems to start but
gets stuck in 0% and fails. I read that there's a restriction and
Android's browser only downloads files the system recognizes, so I
tried setting the type but then I get an exception:

ERROR/AndroidRuntime(23344):
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.VIEW dat=https://server:port/notes/
attachment/91 typ=image/png }

I'm not sure if this matters but the backend of this app is done in
Ruby on Rails and also I know the name and type of file prior trying
to download the file.

I've already implemented a method for the app to handle the file
download but the client wants to be completely sure there's no other
way.

One more thing, this app should support Android 2.1.

Is there a way I can download this file using Android's file?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate