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 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.