android兼容

master
王亚玲 2 years ago
parent 46e3b7a6a0
commit 082ad42cd4

@ -47,7 +47,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.project_telephony" applicationId "com.example.project_telephony"
minSdkVersion 23 minSdkVersion 23
targetSdkVersion 31 targetSdkVersion 33
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName

@ -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;
} }

@ -2,7 +2,7 @@
import 'dart:async'; import 'dart:async';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/ui/home/content_connect_page.dart'; import 'package:project_telephony/ui/home/content_connect_page.dart';

@ -61,6 +61,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
body: Column(children: [ body: Column(children: [
_getRights("获取设备来电状态","用于获取来电状态",plone), _getRights("获取设备来电状态","用于获取来电状态",plone),
_getRights("获取设备短信权限","用于发送短信",sms), _getRights("获取设备短信权限","用于发送短信",sms),
_getRights("获取设备短信权限","用于发送短信",sms),
],) ],)
@ -106,7 +107,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
_getRights( String name,String text,bool state){ _getRights( String name,String text,bool state){
return ListTile( return ListTile(
onTap: ()async{ onTap: ()async{
if(state){ if(!state){
openAppSettings(); openAppSettings();
} }
// if(!(sms && plone)){ // if(!(sms && plone)){

@ -111,6 +111,7 @@ class _UserPageState extends State<UserPage> {
? PloneBottom( ? PloneBottom(
border: false, border: false,
onTap: () async { onTap: () async {
var cancel = CloudToast.loading; var cancel = CloudToast.loading;
var base = await apiClient.request(API.app.logout, var base = await apiClient.request(API.app.logout,
showMessage: true); showMessage: true);
@ -334,10 +335,9 @@ class _UserPageState extends State<UserPage> {
// initializeService(); // initializeService();
// print("这是数据${prefs.getBool("kg")}"); // print("这是数据${prefs.getBool("kg")}");
}else{ }else{
print("false");
prefs.remove("kg"); prefs.remove("kg");
prefs.setBool("kg", vle); prefs.setBool("kg", vle);
service.invoke("stopService"); service.invoke("stopService");///
// exit(0); // exit(0);
// UserTool.userProvider.setKg(vle); // UserTool.userProvider.setKg(vle);
// prefs.setBool("kg", false); // prefs.setBool("kg", false);

Loading…
Cancel
Save