diff --git a/docs/embedded-app-android.html b/docs/embedded-app-android.html index f702778f5a9..7d7eaf1ef53 100644 --- a/docs/embedded-app-android.html +++ b/docs/embedded-app-android.html @@ -1,4 +1,4 @@ -Integrating with Existing Apps – React Native | A framework for building native apps using React

Integrating with Existing Apps

Since React makes no assumptions about the rest of your technology stack, it's easily embeddable within an existing non-React Native app.

Requirements #

  • an existing, gradle-based Android app
  • Node.js, see Getting Started for setup instructions

Prepare your app #

In your app's build.gradle file add the React Native dependency:

compile 'com.facebook.react:react-native:0.13.0'

You can find the latest version of the react-native library on Maven Central. Next, make sure you have the Internet permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

This is only really used in dev mode when reloading JavaScript from the development server, so you can strip this in release builds if you need to.

Add native code #

You need to add some native code in order to start the React Native runtime and get it to render something. To do this, we're going to create an Activity that creates a ReactRootView, starts a React application inside it and sets it as the main content view.

public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler { +Integrating with Existing Apps – React Native | A framework for building native apps using React

Integrating with Existing Apps

Since React makes no assumptions about the rest of your technology stack, it's easily embeddable within an existing non-React Native app.

Requirements #

  • an existing, gradle-based Android app
  • Node.js, see Getting Started for setup instructions

Prepare your app #

In your app's build.gradle file add the React Native dependency:

compile 'com.facebook.react:react-native:0.17.+'

You can find the latest version of the react-native library on Maven Central. Next, make sure you have the Internet permission in your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />

This is only really used in dev mode when reloading JavaScript from the development server, so you can strip this in release builds if you need to.

Add native code #

You need to add some native code in order to start the React Native runtime and get it to render something. To do this, we're going to create an Activity that creates a ReactRootView, starts a React application inside it and sets it as the main content view.

public class MyReactActivity extends Activity implements DefaultHardwareBackBtnHandler { private ReactRootView mReactRootView; private ReactInstanceManager mReactInstanceManager; @@ -38,7 +38,7 @@ protected void onResume.onResume(); if (mReactInstanceManager != null) { - mReactInstanceManager.onResume(this); + mReactInstanceManager.onResume(this, this); } }

We also need to pass back button events to React Native:

@Override public void onBackPressed() {