All Projects → staltz → react-native-android-packagemanager

staltz / react-native-android-packagemanager

Licence: other
Call some PackageManager APIs from React Native

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language

react-native-android-packagemanager

Gives you some access to Android's PackageManager APIs, for instance to read the metadata inside an APK file.

Getting started

$ npm install react-native-android-packagemanager --save

Easy installation

$ react-native link react-native-android-packagemanager

Manual installation

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.reactlibrary.RNAndroidPackagemanagerPackage; to the imports at the top of the file
  • Add new RNAndroidPackagemanagerPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-android-packagemanager'
    project(':react-native-android-packagemanager').projectDir = new File(rootProject.projectDir,   '../node_modules/react-native-android-packagemanager/android')
    
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:
      compile project(':react-native-android-packagemanager')
    

Usage

import RNAndroidPM from 'react-native-android-packagemanager';

RNAndroidPM.getPackageInfo('/storage/emulated/0/myapp.apk')
  .then(info => {
    console.log(info);
    /*
      {
        package: "com.example.myapp",
        label: "My App",
        versionName: "1.2.3",
        versionCode: 3,
        firstInstallTime: 1185920,
        lastUpdateTime: 1283058,
      }
    */
  })
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].