Skip to main content

Downloading files via HTTP to Android flash disk instead of relying on the browser, for better user experience

 

Scenario:

When the user hits a list item within the Android ListView control we would like to open a document in this case its a .pdf document from one of our web sites. The website expects a parameter and serves a pdf, matching the parameter in the request. When a file is not available we get a standard 404.

There are times when you just cannot rely on the browser available on Android handsets to open documents for various reasons, one being you want to pop specific error messages on the screen ie document ‘NAME’ is not available yet and some reasons. Our users did not like the passing the control to the browser from the Android application and then reopen the application to get back to where you were.

 

Solution Discussion

One of the possible solution is to stream the file and write it to and disk and create an activity to open the file on a pdf reader application. PDF readers are shipped with Android which made our lives a lot easier. The small minority who did not have the pdf reader will have problem viewing the file. I am keen to find out how others are handling similar requirements.

 

Here is the item click handler

image

 

This is the function to download and save the pdf file into the disk.

This function itself is simple enough, load a file name and file path and forms a URI.

- Delete any existing file before creating the new file

image

Comments

Popular posts from this blog

Microsoft Dynamics XRM proxies–Early bind in ASP.NET web service

  As a hands on Development Manager I often get to lead by example, in my latest attempt to fast track re-development of some of our Java based web services to ASP.NET web service, I went about this using XRM based early bind method. I also explored SDK and JavaScript to execute the Dynamics rest API. For a starter our web service methods roll up large datasets therefore JSON based service was obviously not suitable. Also the java based services made calls to multiple stored procedures through Hibernate frame work, the idea was to convert any calls to Dynamics CRM using XRM with LINQ and other bits and pieces using NHibernate framework. I am keen to learn alternative methods and very open for feedback on the approach I have taken here. Without further ado here are the steps.   1. Re-Compile XRM to include proxies for Dynamics CRM customisations. This was easily done by executing the following commands within the CrmSvcUtil.cmd file REM $0\..\..\Microsoft.Xrm\bin\CrmSvcU...

External Authentication providers for SharePoint 2010–(Oracle/Sun Directory as user stores)

External Authentication providers for SharePoint 2010: Thank you for continuing to read my blogs. It is a Sunday afternoon and the Roosters are leading Panthers 10 points to 6 in NRL, by the look of it, it has all the signs of turning into a one sided match in the second half. I thought I might write a blog about SharePoint and Single Sign On with Non-Microsoft Technologies. The Problem: Often Organisations would like to utilise their existing stack of technologies with SharePoint. This is due to the popularity of SharePoint as a platform to consolidate and provide a range of application services either to replace an existing set of tools or compliment an existing applications suite. We fall under the latter. I am working within a truly heterogeneous environment at the moment, the extranet applications are built on a mix of technologies such as OpenText Livelink for DMS, Java and JBPM for for workflow and front end portals, Sun Directory and Oracle for User data and other DB La...

Combine agile and rapid prototyping to deliver a successful Microsoft Dynamics CRM project very quickly

  The Situation: If you are in the Software Development space you would have been at some stage, part of a long and winding CRM project. Also the reasons for the lengthy CRM projects range from requirements changing through the course of the project, lack of strong vendor selection process to strong leadership to make critical decisions. There is no silver bullet that can get you through the project without any of the above simply because projects are established and executed by people. How do we tackle a CRM project without much fuss.?   The Solution discussion: Microsoft Dynamics CRM provides the basic building blocks and the tools to extend it to meet your custom requirements. It is also easier to deliver a successful Dynamics CRM project faster by Combining Agile and rapid prototyping. This is exactly the approach being demonstrated here. This approach may not work if you don’t have enough experience within delivery team to estimate work effort accurately and execu...