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).
applicationId "com.example.project_telephony"
minSdkVersion 23
targetSdkVersion 31
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

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

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

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

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

Loading…
Cancel
Save