Skip to content

An Android app to check Hong Kong bus routes and estimated time of arrival (ETA) at each stop.

License

Notifications You must be signed in to change notification settings

adrielyeung/check-my-bus

Repository files navigation

check-my-bus

An Android app to check Hong Kong bus routes and estimated time of arrival (ETA) at each stop, using data from Kowloon Motor Bus Company (1933) Limited (KMB) (incorporating Long Win Bus Company Limited (LWB)), Citybus Limited (CTB) and New World First Bus Services Limited (NWFB) under the OpenAPI initiative of the Hong Kong Government.

How to use

  1. Clone the repository into a local directory.
  2. Open the project directory in Android Studio.

APIs called

1. Route API

In MainActivity, to look up the routes in each company.

2. Route-Stop API

In MainActivity, to determine whether the route is circular (no inbound stops).

In SelectStopActivity, to get all stop IDs of the selected route.

3. Stop API

In SelectStopActivity, to get the stop name, location (latitude and longitude).

4. Stop-ETA API

In SelectTimeActivity, to get the ETA of selected stop.

Description

The app consists of 3 Activities, namely:

  1. MainActivity
  2. SelectStopActivity
  3. SelectTimeActivity

1. MainActivity

MainActivity Initial Screen

Normal routes

The initial screen, allowing users to input route number in EditText. After input, all companies with a route with such number are displayed. Click on a company to show all stops on their route.

MainActivity Input Route

Jointly-operated routes

These are same route operated by one of KMB/LWB & one of CTB/NWFB. The companies operating the route will be displayed as below. (Note that LWB routes are displayed as KMB since no separate API to differentiate.)

MainActivity Input Jointly-operated Route

Circular routes

These are routes that have only 1 terminus, directly returning back to its origin after reaching its outbound destination. Only outbound destination is shown.

MainActivity Input Circular Route

No route found

Alternatively, if no such route is found in any company, an error message is displayed.

MainActivity Input Route Error

2. SelectStopActivity

The screen displays all normal operation bus stops on the route (Note: stops which are served only during diversion are not shown for KMB routes). Click on any stop to view the ETA.

StopActivity

Note: for jointly-operated routes, the stop names of KMB are used by default.

StopActivity Jointly-operated routes

3. SelectTimeActivity

This screen displays the first ETA of the selected route, direction and stop. It displays in both time (UTC+8) and countdown in minutes.

Notes:

3.1 Joint-operation

Both companies' API are called, and stops are matched by latitude and longitude not exceeding 2e-3 degree of each other. (Note: the outbound/inbound directions of cross harbour routes is opposite between KMB and CTB/NWFB but same for non-cross harbour routes.) The earliest ETA is shown on screen. The company TextView will only show the operator of that departure. The destination and stop name will be displayed according to the operator's names.

For example, below N619 (jointly-operated by CTB/KMB) departure at 02:37 is operated by CTB.

TimeActivity

3.2 No ETA found

The ETA API returns departures within an hour. If no ETA is returned, below error message is displayed. It may be due to out of service hours of route or data error. Use the Refresh button to refresh the status.

TimeActivity No ETA

Future developments

  1. Allow app to send notification of ETA of certain route at specified time.

About

An Android app to check Hong Kong bus routes and estimated time of arrival (ETA) at each stop.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages