When it comes to programming, the term routing is more commonly used in web development. In that field of study it refers to the process of determining when a user visits a page by making a HTTP request.
Here is a simple example of a route in web development:
Route::get('/hello', function () { return 'Hello There'; });
However in android when we talk about routing we simply mean navigation. Android apps are client-side software therefore do not receive HTTP requests like web servers. But we typically need to navigate between activities and fragments.
We typically do these via intents and pass data via bundles. However developers have been creating libraries to make this navigation easier and more intuitive. These libraries are what we call routing libraries and it is the aim of this thread to discuss them.
If you’ve come across any library or example please feel free to contribute it here.
Oclemy
Linker
Linker is a library written in Kotlin that provides an annotation-based API to handle URI routing for Android. Linker provides not only simple navigation but the ability to query a Uri.
Here is how it’s used:
Step 1.
The first step is to install the library:
There are two parts of Linker:
(a). Annotations
With annotations:
You can use @link to indicate the Uri that was requested.
Then
@LinkPath
@LinkQuery
for parameters(b). LinkResolver
Here is how LinkResolve is defined:
Function
resolve
will parse the given link, and then return aResult
, which has a nullable property ofIntent
, it will be null if no responding activities was found,Routing:
Download
Here are the links: