How it works...
In this recipe, we mimicked the functionality we created in the Background processing on iOS recipe on Android. We created an Android native module with a method which, when invoked, performs arbitrary execution in the background (sleep for five seconds). When the process is complete, it emits an event to the React Native layer, whereupon we update the app UI to reflect the status of the background process. Android has multiple options for performing multithreaded operations natively. In this recipe, we used AsyncTask, since it is geared towards short-running (several seconds) processes, it is relatively simple to implement, and the operating system manages thread creation and resource allocation for us. You can read more ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access