Best way to gather data from a website for an Android application
-
29-05-2021 - |
Question
I'm trying to put together a new app for a project that will display train times for the user.
I know there are a couple of ways to go about this, but before I get started I wanted to get some help from you.
My options
- use a webview
- Use a database linked to the website that has all of the data
- Hard code all of the times
- Ask the website for the data/access to the data.
This is the site: http://www.njtransit.com/sf/sf_servlet.srv?hdnPageAction=LightRailTo
I was looking in the source to see if I could find anything, but came up blank.
Solution
Method #4 is the best way. Request access to their webservice that gives you results in xml/json. Your Android App then parses it and then display's it according to it's UI and give users some extra features that the website can't provide.
Method 1) Use a webview - (well, technically the easiest...but if you are simply opening the webpage, why should i use your application when a browser can do the same?)
Method 2) More or less the same as Method #4
Method 3) Train schedules might change, you'll have to update your app frequently.