Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

90
Visualizações
Reduce time for calling native module methods in react-native application

I implemented a native module which navigates to a camera activity. But while calling the camera from nativeModules, it takes 1500-2000ms to open(excluding ui updation in camera).

The native module class that extends ReactContextBaseJavaModule is written like this:

@ReactModule(name = ImagePickerModule.NAME)
public class ImagePickerModule extends ReactContextBaseJavaModule
        implements ActivityEventListener
{
   ....
   // Calling this method
   @ReactMethod
   public void launchCamera(final ReadableMap options, final Callback callback) {
      // this method opens camera after checking necessary permissions and applies UI changes which was set by the user previously
   }
   ....
}

And this is nativeModules to JS mapping in the .ts file

import {NativeModules} from 'react-native';
import {ImagePickerNativeModule} from './privateTypes';

const NativeInterface: ImagePickerNativeModule | undefined =
  NativeModules.ImagePickerManager;

const DEFAULT_OPTIONS: ImagePickerOptions = {
   // options here
}

class ImagePicker {
  launchCamera(options: ImagePickerOptions, callback: Callback): void {
    return NativeInterface.launchCamera(
      {
        ...DEFAULT_OPTIONS,
        ...options,
        tintColor: processColor(options.tintColor || DEFAULT_OPTIONS.tintColor),
      },
      callback,
    );
  }
}

I am calling the nativeModule from react-native code like this:

export const CustomCamera = (): Promise<{ uri: string }> => {
    return new Promise((resolve, reject) => {
        ImagePicker.launchCamera(***Camera options passed***)
          .then(res => // Do something here)
          .catch(err => // Do something here)
    }
}

Is there any way I can open the activity faster while calling it from native modules? or keep the activity in the background so that the cameraActivity can load fast while calling it from react-native? Please suggest.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda