|
|
@ -48,7 +48,7 @@ void onStart(ServiceInstance service) async {
|
|
|
|
service.on('stopService').listen((event) {
|
|
|
|
service.on('stopService').listen((event) {
|
|
|
|
service.stopSelf();
|
|
|
|
service.stopSelf();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
Telephony.backgroundInstance.sendSms(to: "13486828191", message: "123123");
|
|
|
|
Timer.periodic(const Duration(seconds: 1), (timer) async {
|
|
|
|
Timer.periodic(const Duration(seconds: 1), (timer) async {
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
|
|
|
CallState state = await Telephony.instance.callState;
|
|
|
|
CallState state = await Telephony.instance.callState;
|
|
|
@ -57,9 +57,8 @@ void onStart(ServiceInstance service) async {
|
|
|
|
String? ref = prefs.getString('refSms');
|
|
|
|
String? ref = prefs.getString('refSms');
|
|
|
|
String? con = prefs.getString('conSms');
|
|
|
|
String? con = prefs.getString('conSms');
|
|
|
|
// print(con);
|
|
|
|
// print(con);
|
|
|
|
|
|
|
|
|
|
|
|
if (callState == "IDLE") {
|
|
|
|
if (callState == "IDLE") {
|
|
|
|
print(flag);
|
|
|
|
print("flag$flag");
|
|
|
|
if (flag != 0) {
|
|
|
|
if (flag != 0) {
|
|
|
|
final Iterable<CallLogEntry> entry = await CallLog.query();
|
|
|
|
final Iterable<CallLogEntry> entry = await CallLog.query();
|
|
|
|
phoneNum = entry.first.number;
|
|
|
|
phoneNum = entry.first.number;
|
|
|
@ -68,9 +67,11 @@ void onStart(ServiceInstance service) async {
|
|
|
|
if (flag > 0) {
|
|
|
|
if (flag > 0) {
|
|
|
|
print("2");
|
|
|
|
print("2");
|
|
|
|
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!);
|
|
|
|
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!);
|
|
|
|
|
|
|
|
print("发送成功");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
print("3");
|
|
|
|
print("3");
|
|
|
|
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
|
|
|
|
Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!);
|
|
|
|
|
|
|
|
print("发送成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
flag = 0;
|
|
|
|
flag = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|