Easily retrieve information about the current Android build synchronously.
Important
This package is currently experimental and may change in non-breaking ways in the future. version 0.X.X still in development and may not ready for production use.
Example
install example app
cd example
flutter pub get
flutter build apk --target-platform android-arm64
flutter install --release
Usage
Add package
- run in command line
flutter pub add android_os_build
- or add to
pubspec.yaml
...
dependencies:
android_os_build: any
...
Get build information
import 'package:android_os_build/android_os_build.dart';
final model = Build.model;
final sdkInt = Build.version.sdkInt;
AndroidBuild.getSerial()
requireandroid.permission.READ_PRIVILEGED_PHONE_STATE
permission, so if you want to get serial number, you need to add this permission to yourAndroidManifest.xml
file.<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" /> ...... </manifest>
Direct use generated ffi code
import 'package:android_os_build/android_os_build_jni.dart';
String getBoard() {
final JString board = Build.BOARD;
/// return value and release the string object
return board.toDartString(releaseOriginal: true);
}
Development
you should build apk first then run jnigen
cd example
flutter build apk
cd ..
flutter pub run jnigen --config jnigen.yaml
License
- package is under MIT license
The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.