RSS

Category Archives: HyperNext Android

9 How To: RSS and News Feeds

RSS is a term that encompasses a number of web feed formats used in the publication of frequently updated works such as information on news-related sites, blogs, forum posts. Articles can contain both text and links to media such as images, movies etc.

What does RSS actually stand for? – there are several expansions of the term RSS such as Really Simple Syndication, Rich Site Summary etc. Here some descriptions of RSS:-

RSS Explained:-
http://www.whatisrss.com/

Wikipedia RSS
http://en.wikipedia.org/wiki/RSS

.
The most commonly used formats are RSS followed by Atom. HAC can process both these formats plus some custom formats as well. It can also process sources from either a URL or a text file. Usually the term RSS is generic and refers to RSS plus Atom and custom formats.
.
With HAC, users do not have to specify the format because HAC tries to be flexible and process as much of each article as possible. For each article it is asked to keep, it saves every field it can parse, and also saves their field names. This allows the programmer/user to decide which fields to use. Fields are created by HAC in the order in which they were found.

Apps handling news feeds need some protection because RSS feeds can potentially be huge and any attempt to download/process the entire feed could cause a memory exception in the app. Therefore HAC allows feeds to be interrogated for their size and has options to process a specified range of articles. For instance, if there were 1000 articles in the source, then the user might like to just look at articles in the range 100 to 150 without downloading/parsing the entire source.
.
.
Example Feeds
Here are some example feeds used in testing the HAC RSS example project.

Atom feed
http://blog.case.edu/news/feed.atom

HAC Forums RSS:-
http://www.tigabyte.com/forum/index.php?action=.xml;type=rss

BBC News Feed:-
http://feeds.bbci.co.uk/news/world/middle_east/rss.xml

Global Sport feed:-
http://globoesporte.globo.com/dynamo/futebol/times/vasco/rss2.xml
.
.
Reading Feeds
There are 3 steps in using RSS

  1. Get feed from URL or a file.
  2. Parse the feed for articles.
  3. Examine or display articles.

The format of articles is explained below.

.

Feeds and Articles

Feeds are comprised from a number of articles and each article can have several named fields although there can be more than one field with the same name. The situation can be more complex though as some sources use custom formats where fields have sub fields etc. Custom formats are more complex to parse and HAC RSS parsing currently doesn’t support them as its parser just looks for top level elements/fields.

The list below shows comparative field names for RSS and Atom although there is nothing to stop sources having their own unique field names:

.
.

EXAMPLE: Creating an RSS Reader

Here we will show you the scripts behind a basic RSS reader that can work with the formats: RSS, Atom and some custom ones. As mentioned above there are 3 stages to reading an RSS feed although HAC combines both the fetch and parse stages into one function. Note, for clarity, it does not show any error checking.

a) Open and Parse Feed

To parse an RSS source use the RssParseSourceFN function. This function returns a count of the number of articles found although if an error occurred it returns -1. It automatically stores any retrieved articles and their field names so later they can be processed or displayed. Note, for app safety, a maximum article limit must be specified so for instance if the feed contained a million articles then your app could limit itself to just 100 articles. There is also a start value that enables a number of articles to be skipped.

The code below shows how to parse an RSS feed:-

@ --- Reads BBC news source ---
Local mode,source,start,max

@ read from URL so set mode = 2 (=1 for file)
PUT 2 INTO mode

@ Set URL
PUT 'http://feeds.bbci.co.uk/news/world/middle_east/rss.xml' INTO source

@ Set limits
PUT 1 INTO start
PUT 100 INTO max

@ Retrieve and parse source
PUT RssParseSourceFN(mode,source,start,max) INTO field 1

@ Display article count found
PUT RssArticleCountFN INTO field 2

.
It you just want to count how many articles are in the source then use the RssParseCountFN function. This parses the source but does not store any articles. Again, for safety it requires the maximum number of articles to parse. The example below shows how to do this.

@ --- Reads BBC news source ---
Local mode,source,max

@ read from URL so set mode = 2 (=1 for file)
PUT 2 INTO mode

@ Set URL
PUT 'http://feeds.bbci.co.uk/news/world/middle_east/rss.xml' INTO source

@ Set limits
PUT 10000 INTO max

@ Parse and count source
PUT RssParseCountFN(mode,source,max) INTO field 1

.

b) Accessing Retrieved Articles

Once the articles are retrieved to memory then they can be processed and displayed. The RssArticleCountFN returns the number of articles previously retrieved and can be used to loop over the articles.

Each article has a number of named fields such as AUTHOR, CATEGORY, DESCRIPTION etc. There is no restriction though on uniqueness of the field names so for example an article might have several fields named DESCRIPTION. Furthermore, articles within the same feed can have different numbers of fields and different field names. The number of field names and a list of their names can be retrieved using the functions RssFieldCountFN and RssFieldNamesFN respectively. Note, all field names are forced to uppercase. There is also a function called RssFieldListFN that returns in list form the name of every field found in the source.
.
The script below shows how to retrieve the contents of a known named field called DESCRIPTION from article number 5.

@ --- Display DESCRIPTION field of article 5 ---

PUT RssFieldByNameFN(5,'DESCRIPTION') INTO field 1

.
.

The script below shows how to loop over all of the fields in article 5.

@ --- Displays article 5 ---
Local aid,count,f

@ set article number
PUT 5 INTO aid

@ how many fields
PUT RssFieldCountFN(aid) INTO count

@ Loop over all fields and place into text field 1
Clear field 1
FOR f=1 TO count
   PUT RssFieldByNumberFN(aid,f) AFTER field 1
ENDFOR

.
.
c) Tidying Up

Once you have finished using the retrieved articles it is a good idea to clean up and free the memory they occupied, especially if hundreds or more articles were retrieved. The RssClear command frees memory used for storing all article headers, fields and articles themselves.

@ --- Clear memory used by RSS ---

RssClear

.
.

.
Summary
This article shows how to create a very simple RSS reader using HAC and briefly looks at a few of its RSS commands/functions. For more details see the project link below.

With HAC an RSS app can:

  1. Read RSS, Atom and some custom formats.
  2. Read from either a URL feed or a text file.
  3. Limit the number of articles parsed
  4. Skip articles and retrieve just a range.

For more information about creating RSS apps with HAC, look at HAC’s built-in help or its HAC Help pdf.

There is an RSS project and its built app on our examples web page http://www.hypernextandroid.com/hnfiles/rescreator.html The project example is only test bed that demonstrates HAC’s RSS functionality.

.

Members of HAC forums can download the latest trial version of HAC, see details here:- http://www.hypernextandroid.com/hnfiles/downloads.html

 

HAC v1.16 with RSS news reading

HAC v1.16 released for Windows (2nd November 2012 )

This update adds parsing of News Feeds(RSS), transparent fields plus better debugging during HAC startup. There are also some memory usage improvements and some minor bug fixes.

The News Feed functionality supports both RSS and Atom formats. It also allows feeds from both URLs and files to be parsed. It can cope with huge feeds and allows the user to skip unwanted articles and just store the sequence they need.

The HAC startup debugging makes it much easier for users with installation problems to find out where the problem is.

For further details see the release notes accompanying HAC and the posts listed in our forums.

HAC apps can run on Android OS API 1.6 up to the latest 4.1 (Jelly Bean).

For further details see the release notes accompanying HAC and the posts listed in our forums

http://www.tigabyte.com/forum/index.php?topic=202.0

Thank you again to our forum users and others for submitting such valuable feedback.

 

Android Apps – No Coding Development?

For anyone wanting to create their own Android app, the options can seem bewildering. Options range from so called No-Coding app makers to the standard Google Android Java approach.

Most of us tend to pick the easiest options, and this can be fine for many tasks. However when creating software it is usually  best to consider the options because they can have long term implications. Choosing the wrong option can waste both your time and your money.

There are basically two quite different approaches to creating Android apps:-

  1. For those comfortable with programming – Eclipse Java and the Android SDK.
  2. For those new to programming – No-Coding Template based app makers.

HAC is in the middle ground as it offers an easy to understand coding language and visual designer.

There are also tools like App Inventor that make programming easy with their coloured blocks/segments although they are harder to use for larger projects.
.

Code – just instructions

Code is just a list of instructions that tells the computer how to carry out a task.

There is no need to fear coding and if one follows some basic steps then the coding will be easier.

So if you try to break the task into smaller pieces it can be easier to design and create the code.

Perhaps the reason so many people try the No-Coding approach is because the Java approach and its Object Orientated aspects has a tough learning curve. HAC tries to make coding easier as each HAC English-like instruction executes a number of often complex Java instructions so hiding much of the complexity from the coder.
.

No-Coding Approach

The No-Coding aproach is very attractive and can produce some impressive looking apps.

Such app makers work by allowing the creator to select a template for a particular task and then personalise or tune the template to their needs. Usually the template changes are mainly to do with their appearance and content but not with functionality. Changing functionality generally needs code changes.

To make an app that way is very simple. Select the template, modify the template and click the build app button. The built app will then be emailed to you after 10 minutes or will be available to download.

However, what about unsupported functionality? For instance, suppose the template can do a task once but you need it to do the task several times and each time process the data before displaying it. In this case you would need to learn some HTML/Javascript. Unfortunately HTML/Javascript are both limited in the functionality they can provide and have limitations in updating displays and handling user feedback. This might not be a problem for your app but its wise to check the web site’s forum posts to see how they implement the functions your app will need.

If you intend to charge money for your app then you might try to deter piracy by some kind of registration scheme using name/address and a serial number. If you are lucky then the app maker might provide this functionality otherwise you will need to code your own scheme.
.

Where is the Code?

Generally, the code will reside on their No-Coding web server and will be innaccessible inside the template. Although any custom code you made such as HTML and Javascript could be saved onto your own computer.

Being able to see the code can be important if you want to understand how it works, improve it or sell it to someone else.

Of course, if you are happy with the standard template then the issue of code does not arise
.

Who Owns Your App?

The issue of who actually owns your app and its code can be very important.

Ownership of the app can be a grey area as some No-Coding sites say you are only granted non-exclusive rights to your creation. They explain that this is because of the way their template works inside the app’s runtime engine and that the templates are used by others.

There is also the issue of will the app look like your app. That is, will it display you as creator or will it display the No-Coding website’s name.

If you want to own your app then make sure you read their agreement and are happy with it.
.

Subscription Issues

With traditional fixed term licensed software, when the license expires the software keeps on working but cannot be updated. Therefore the owner can keep on developing their apps.

With a No-Coding app maker, what happens when your Subscription expires? Is your app locked or can you still access it, see its details or export it? Also will you still be able to modify or rebuild your app?

Is there a limit of how many apps you can make with the subscription or are there extra charges?

Its worthwhile reading their FAQ to see what the subscription offers.
.

HAC Advantages

Although No-Coding app makers can produce some excellent results they are limited by the number of available templates. With time they will get even better as more templates and functionality are added. However, if you need something special and their template system doesn’t support it, then generally you will have to learn HTML/Javascript and incorporate it into the template.

Comparing HAC to No-Coding app makers:-

  1. Your HAC license lasts forever – no subscriptions.
  2. Security, as your projects and code are stored on your own computer.
  3. Having your own source code puts you in control.
  4. Code is infinitely more flexible than template systems.
  5. To make money, you probably need unique ideas – not templates.

In summary, check out what the No-Coding maker offers and you might find that they offer just what you need.

Bear in mind that HAC doesn’t offer full Android functionality so No-Coding could be the route to go.

Finally, don’t be afraid of coding – its just telling a computer how to carry out a task.

 

HAC v1.15 with Database Support

HAC v1.15 released for Windows (24th August 2012 )

This update adds SQLite database support, status bar notifications, fullscreen mode, AES cypher, Base 64, Toast Message and some further boolean/conversion functions. There are also memory performance improvements and some bug fixes.

The SQLite database functions can work either with database files on an app’s internal protected file space or on the external SD card.

HAC apps can run on Android OS API 1.6 up to the latest 4.1 (Jelly Bean).

For further details see the release notes accompanying HAC and the posts listed in our forums

http://www.tigabyte.com/forum/index.php?topic=190.0

Thank you to our forum users and others for submitting such valuable feedback.

 

HAC v1.14 with UDP Messaging

HAC v1.14 released for Windows (25th May 2012 )

This update adds UDP messaging plus improvements and bug fixes.

UDP messaging is an easy to use communications protocol that is ideal for messaging between apps in local networks such as in schools and businesses. It allows fast communications and can also interact with hardware that supports the UDP protocol.

For further details see the release notes accompanying HAC and the posts listed in our forums

http://www.tigabyte.com/forum/index.php

Thank you to our forum users and others for submitting such valuable feedback.

 
 

HAC Prize Draw

HAC Prize Draw(14th Nov 20011 )

FIVE full versions of HAC to be won!

Enter our Prize Draw and win one of FIVE full versions of HAC.

Just fill in our simple questionnaire about HAC and our website.

Our competition starts Monday 14th November and lasts for 7 days.

Only forums members can enter our Prize Draw:

http://www.tigabyte.com/forum/index.php

 

HAC v1.07 for Presentation Type Apps

This update adds several card commands that are useful for creating presentation type apps such as our Solar System example project whose Android tablet screen shot is shown below. Users navigate the app by touching the planetary objects which then opens a card displaying information about that object. This touch navigation  is implemented by invisible canvases overlaying the card image and is a much simpler method than storing and comparing hot spot coordinates.

Solar System screen shot

HAC v1.07 also has improvements to card loading, canvases and file handling.

For a list of improvements and bug fixes see the release notes accompanying HAC and the posts listed in our forums.

Thank you to our forum users and others for submitting such valuable feedback.