Skip to content

lequanghuylc/react-native-restart-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-restart-android

Restart the whole react native android application

Note: this project is Android only

Installation Process

  • download this from npm
npm install react-native-restart-android --save
  • Run react-native link to automatically link the library.

manual link process

  • Edit android/settings.gradle:

    + include ':react-native-restart-android'
    + project(':react-native-restart-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-restart-android/android')
  • Edit android/app/build.gradle:

    dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile "com.android.support:appcompat-v7:23.0.1"
      compile "com.facebook.react:react-native:+"
    + compile project(':react-native-restart-android')
    }
  • Edit android/app/src/main/java/.../MainApplication.java:

    + import com.rnrestartandroid.RNRestartAndroidPackage;
      @Override
      protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
          new MainReactPackage()
    +     , new RNRestartAndroidPackage()
        );
      }

Usage

import RestartAndroid from 'react-native-restart-android'
// or
import { RestartAndroid } from 'react-native-restart-android'
// or
const RestartAndroid = require('react-native-restart-android')

// methods (Android only, will throw Error on iOS)
RestartAndroid.restart()

About

Restart the whole react native android application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published