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\CrmSvcUtil /code

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
LEARNING TO FLY WITH WITH LEARN TO FLY - MELBOURNE   SEPTEMBER 5, 2018   LTF student Balendran Thavarajah has just successfully completed his first solo flight. We thought it would be a great idea to share his flight story, to show you that it is possible to juggle a busy professional and family life with your dream of learning to fly. LTF: YOU’RE CURRENTLY COMPLETING YOUR RPC – WHAT’S YOUR END GOAL WITH FLYING? Balendran: In the short term, I would like to complete my RPC with passenger and cross-country endorsements. Ultimately, I want to obtain a Private Pilot Licence. WHAT MADE YOU WANT TO LEARN HOW TO FLY? I was fascinated by planes and the idea of an aircraft moving through the air. As a kid, I wanted to be a fighter jet pilot but, growing up in Northern Sri Lanka during a prolonged civil war provided no such opportunities. After arriving in Australia, I realised that private aviation was not for the privileged alone. Last year,