Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/staltz/react-native-android-packagemanager
Call some PackageManager APIs from React Native
https://github.com/staltz/react-native-android-packagemanager
Last synced: 4 days ago
JSON representation
Call some PackageManager APIs from React Native
- Host: GitHub
- URL: https://github.com/staltz/react-native-android-packagemanager
- Owner: staltz
- Created: 2017-10-19T13:34:00.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-10T15:08:14.000Z (over 6 years ago)
- Last Synced: 2024-12-24T20:38:27.701Z (18 days ago)
- Language: Java
- Size: 6.84 KB
- Stars: 21
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-react-native-native-modules - react-native-android-packagemanager ★12
README
# react-native-android-packagemanager
Gives you some access to Android's [PackageManager](https://developer.android.com/reference/android/content/pm/PackageManager.html) 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
2. 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')
```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
```
compile project(':react-native-android-packagemanager')
```## Usage
```javascript
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,
}
*/
})
```