Opening downloaded files in Steel

12 views
Skip to first unread message

Daniel

unread,
Jun 12, 2009, 2:31:38 AM6/12/09
to SteelAndroid
I recently took the plunge and bought a PDF viewer in the Market. This
has revealed one of the very few shortcomings of Steel compared to the
built-in browser, which allows you to invoke the relevant application
after the file finishes downloading.

It's hardly a super-huge hassle to simply save the file and open it
manually, but I just wanted to request this feature because it would
be pretty slick. It looks like all the built-in browser does to
achieve this effect is the following (run when an item in the download
list is clicked):

int filenameColumnId =
mDownloadCursor.getColumnIndexOrThrow(Downloads._DATA);
String filename = mDownloadCursor.getString(filenameColumnId);
int mimetypeColumnId =
mDownloadCursor.getColumnIndexOrThrow
(Downloads.COLUMN_MIME_TYPE);
String mimetype = mDownloadCursor.getString(mimetypeColumnId);
Uri path = Uri.parse(filename);
// If there is no scheme, then it must be a file
if (path.getScheme() == null) {
path = Uri.fromFile(new File(filename));
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, mimetype);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
new AlertDialog.Builder(this)
.setTitle(R.string.download_failed_generic_dlg_title)
.setIcon(R.drawable.ssl_icon)
.setMessage(R.string.download_no_application)
.setPositiveButton(R.string.ok, null)
.show();
}

So if Steel did something similar (and simply did nothing if
startActivity failed due to no application associated with that MIME
type), that would be truly excellent!

Daniel

kolbysoft

unread,
Jun 12, 2009, 8:54:51 AM6/12/09
to SteelAndroid
Daniel,

thanks for posting the code :) It's not like steel doesn't already do
it for video links. I'll look into adding a dialog after downloads are
finished to prompt the user to open the file.

However,
I was going to revamp the whole downloading part, to enable having
multiple asynchronous downloads, so I'm trying to avoid touching new
stuff for downloading before that's done.

Anyway, thanks for the suggestion, not sure when and how it will go in
yet,

Michael
Reply all
Reply to author
Forward
0 new messages