diff --git a/zxscanner/android/app/src/main/AndroidManifest.xml b/zxscanner/android/app/src/main/AndroidManifest.xml
index bcd50cc..8e1840e 100644
--- a/zxscanner/android/app/src/main/AndroidManifest.xml
+++ b/zxscanner/android/app/src/main/AndroidManifest.xml
@@ -25,6 +25,10 @@
+
+
+
+
diff --git a/zxscanner/lib/configs/app_store.dart b/zxscanner/lib/configs/app_store.dart
index bd5e63c..a5484d7 100644
--- a/zxscanner/lib/configs/app_store.dart
+++ b/zxscanner/lib/configs/app_store.dart
@@ -15,6 +15,8 @@ const String isVibrationOnPref = 'isVibrationOnPref';
const String languagePref = 'languagePref';
abstract class AppStoreBase with Store {
+ static bool isExternCall = false;
+
@observable
ThemeMode themeMode = ThemeMode.system;
diff --git a/zxscanner/lib/main.dart b/zxscanner/lib/main.dart
index 8b4dd26..29e9823 100644
--- a/zxscanner/lib/main.dart
+++ b/zxscanner/lib/main.dart
@@ -1,8 +1,10 @@
+import 'dart:io' show Platform;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter_zxing/flutter_zxing.dart';
+import 'package:receive_intent/receive_intent.dart';
import 'configs/app_store.dart';
import 'configs/app_theme.dart';
@@ -31,6 +33,23 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State {
final AppRouter _appRouter = AppRouter();
+
+ @override
+ void initState() {
+ super.initState();
+ _init();
+ }
+
+ Future _init() async {
+ if (Platform.isAndroid) {
+ final receivedIntent = await ReceiveIntent.getInitialIntent();
+ if(receivedIntent?.fromPackageName != null){
+ AppStoreBase.isExternCall = true;
+ }else{
+ AppStoreBase.isExternCall = false;
+ }
+ }
+ }
@override
Widget build(BuildContext context) {
diff --git a/zxscanner/lib/pages/scanner_page.dart b/zxscanner/lib/pages/scanner_page.dart
index 3c800a2..5fd46c5 100644
--- a/zxscanner/lib/pages/scanner_page.dart
+++ b/zxscanner/lib/pages/scanner_page.dart
@@ -1,6 +1,9 @@
+import 'dart:io' show Platform;
import 'package:flutter/material.dart';
import 'package:flutter_zxing/flutter_zxing.dart';
+import 'package:receive_intent/receive_intent.dart';
+import '../configs/app_store.dart';
import '../models/models.dart' as model;
import '../utils/db_service.dart';
import '../utils/extensions.dart';
@@ -34,5 +37,10 @@ class _ScannerPageState extends State {
final model.Code code = model.Code.fromCodeResult(result);
DbService.instance.addCode(code);
context.showToast('Barcode saved:\n${code.text ?? ''}');
+ if (Platform.isAndroid) {
+ if(AppStoreBase.isExternCall) {
+ ReceiveIntent.setResult(kActivityResultOk, data: {"SCAN_RESULT": "${code.text ?? ''}"}, shouldFinish:true);
+ }
+ }
}
}
diff --git a/zxscanner/pubspec.yaml b/zxscanner/pubspec.yaml
index 9078130..2db1d5c 100644
--- a/zxscanner/pubspec.yaml
+++ b/zxscanner/pubspec.yaml
@@ -30,6 +30,7 @@ dependencies:
share_plus: ^7.0.0
shared_preferences: ^2.0.0
url_launcher: ^6.1.11
+ receive_intent: any
flutter_intl:
main_locale: en_US