android_os_build 0.0.3+1
android_os_build: ^0.0.3+1 copied to clipboard
android information about the current build, extracted from system properties.built with dart's experimental jnigen
Information about the current build, extracted from system properties.
Important
This package is currently experimental and may change in non-breaking ways in the future.
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 = AndroidBuild.model;
final sdkInt = AndroidBuild.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 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