From c234953183032da4be58d4f6555630e6da098a1e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 19 Jan 2016 22:36:39 +0000 Subject: [PATCH] update website --- docs/native-modules-android.html | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/native-modules-android.html b/docs/native-modules-android.html index 953b43f2fee..428bb8ead5b 100644 --- a/docs/native-modules-android.html +++ b/docs/native-modules-android.html @@ -49,14 +49,11 @@ ReadableArray - modules.add(new ToastModule(reactContext)); return modules; - }

The package needs to be provided to the ReactInstanceManager when it is built. To accomplish this you will need to insert an .addPackage(new YourPackageName()) call to the mReactInstanceManager = ReactInstanceManager.builder() call chain.

Refer to the code below and add the addPackage statement to your application's MainActivity.java file. This file exists under the android folder in your react-native application directory. The path to this file is: android/app/src/main/java/com/your-app-name/MainActivity.java.

mReactInstanceManager = ReactInstanceManager.builder() - .setApplication(getApplication()) - .setBundleAssetName("AnExampleApp.android.bundle") - .setJSMainModuleName("Examples/AnExampleApp/AnExampleApp.android") - .addPackage(new AnExampleReactPackage()) // <-- Add this line with your package name. - .setUseDeveloperSupport(true) - .setInitialLifecycleState(LifecycleState.RESUMED) - .build();

To make it simpler to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of NativeModules each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.

'use strict'; + }

The package needs to be provided in the getPackages method of the MainActivity.java file. This file exists under the android folder in your react-native application directory. The path to this file is: android/app/src/main/java/com/your-app-name/MainActivity.java.

protected List<ReactPackage> getPackages() { + return Arrays.<ReactPackage>asList( + new MainReactPackage(), + new AnExampleReactPackage()); // <-- Add this line with your package name. +}

To make it simpler to access your new functionality from JavaScript, it is common to wrap the native module in a JavaScript module. This is not necessary but saves the consumers of your library the need to pull it off of NativeModules each time. This JavaScript file also becomes a good location for you to add any JavaScript side functionality.

'use strict'; /** * This exposes the native ToastAndroid module as a JS module. This has a * function 'show' which takes the following parameters: