How to do it...

  1. Let's start by opening the Android project in Android Studio. In Android Studio, select Open an existing Android Studio project and open the android directory of the new project.
  2. We'll need two new Java classes: BackgroundTaskManager and BackgroundTaskPackage.
  3. Now that both classes have been created, let's open BackgroundTaskManager.java and begin implementing the native module that will wrap an AsyncTask operation, starting with imports and defining the class. Furthermore, like any other native Android module, we'll need to define the getName method, used to provide React Native with a name for the module, as follows:
package com.multithreadingapp;import android.os.AsyncTask;import com.facebook.react.bridge.Arguments;

Get React Native Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.