master
戴余标 2 years ago
parent 70723dcdb6
commit 5c6aafe32d

@ -81,7 +81,7 @@ void onStart(ServiceInstance service) async {
flag = 0; flag = 0;
// print("object"); // print("object");
final Iterable<CallLogEntry> entry = await CallLog.query(); final Iterable<CallLogEntry> entry = await CallLog.query();
phoneNum=entry.first.number; phoneNum = entry.first.number;
callRecords = entry.first.duration; callRecords = entry.first.duration;
// print(prefs.getString('action')); // print(prefs.getString('action'));
// DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!) // DateTime.fromMillisecondsSinceEpoch(entry.first.timestamp!)
@ -92,10 +92,10 @@ void onStart(ServiceInstance service) async {
// // } // // }
// }else{ // }else{
// print("没接通"); // print("没接通");
if(callRecords!=0){ if (callRecords != 0) {
print("接通了"); print("接通了");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了"); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了");
}else{ } else {
print("没接通"); print("没接通");
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了"); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: "接通了");
// if(kg!) { // if(kg!) {
@ -114,9 +114,9 @@ void onStart(ServiceInstance service) async {
flag++; flag++;
// print('flag $flag'); // print('flag $flag');
} else if (callState == "OFFHOOK") { } else if (callState == "OFFHOOK") {
flag++; flag++;
// print('flag $flag'); // print('flag $flag');
} }
}
}); });
} }

@ -2,6 +2,7 @@ import 'package:bot_toast/bot_toast.dart';
import 'package:flustars/flustars.dart'; import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/login/login_page.dart'; import 'package:project_telephony/ui/login/login_page.dart';

Loading…
Cancel
Save