中国能源建设集团采购网站进不去做网站工作辛苦吗

张小明 2026/3/2 16:32:08
中国能源建设集团采购网站进不去,做网站工作辛苦吗,高考毕业做家教网站,网站做实名验证前两篇咱们分别搞定了通知服务#xff08;发送提醒#xff09;和地理位置服务#xff08;获取位置#xff09;#xff0c;这篇咱们先学习设备信息#xff08;deviceInfo#xff09;的核心用法#xff0c;适配不同设备的硬件和系统特性#xff0c;再将三大服务整合发送提醒和地理位置服务获取位置这篇咱们先学习设备信息deviceInfo的核心用法适配不同设备的硬件和系统特性再将三大服务整合完成 “位置提醒 APP” 的完整开发。让咱们从设备适配到功能闭环一步步实现可直接复用的实战项目一、设备信息服务核心认知1. 设备信息的应用价值设备适配根据屏幕尺寸调整 UI 布局、根据系统版本适配 API功能优化根据设备型号调整定位策略如高端机支持高精度 GNSS问题排查记录设备信息用于日志分析快速定位兼容性问题个性化服务根据设备特性提供定制化功能如平板端显示更多操作入口。2. 核心 API 与可获取信息核心模块ohos.deviceInfo设备信息、ohos.screen屏幕信息关键信息设备基础信息型号、厂商、设备 ID系统信息系统版本、API 版本、设备类型屏幕信息屏幕尺寸、分辨率、像素密度。二、设备信息获取实战1. 获取设备基础信息import deviceInfo from ohos.deviceInfo; /** * 获取设备基础信息 */ export function getDeviceBaseInfo(): { deviceModel: string; // 设备型号 manufacturer: string; // 设备厂商 osVersion: string; // 系统版本 apiVersion: number; // API版本 deviceType: string; // 设备类型phone/tablet/watch等 } { return { deviceModel: deviceInfo.deviceModel, // 如Mate 60 Pro manufacturer: deviceInfo.manufacturer, // 如Huawei osVersion: deviceInfo.osVersion, // 如4.0.0.188 apiVersion: deviceInfo.apiVersion, // 如10 deviceType: deviceInfo.deviceType // 如phone }; }2. 获取屏幕信息适配 UI 布局import screen from ohos.screen; /** * 获取屏幕信息 */ export function getScreenInfo(): { screenWidth: number; // 屏幕宽度像素 screenHeight: number; // 屏幕高度像素 density: number; // 像素密度 dpi: number; // 屏幕DPI } { const mainScreen screen.getDefaultScreen(); const screenRect mainScreen.getRect(); const density mainScreen.getDensity(); const dpi mainScreen.getDpi(); return { screenWidth: screenRect.width, screenHeight: screenRect.height, density: density, dpi: dpi }; }3. 设备适配实战根据设备类型调整功能/** * 根据设备类型调整定位配置 * 手机高精度模式平板平衡模式手表低功耗模式 */ export function getLocationConfigByDeviceType(): geoLocationManager.LocationRequest { const deviceInfo getDeviceBaseInfo(); let priority: geoLocationManager.LocationRequestPriority; switch (deviceInfo.deviceType) { case phone: priority geoLocationManager.LocationRequestPriority.HIGH_ACCURACY; break; case tablet: priority geoLocationManager.LocationRequestPriority.BALANCED; break; case watch: priority geoLocationManager.LocationRequestPriority.LOW_POWER; break; default: priority geoLocationManager.LocationRequestPriority.BALANCED; } return { priority: priority, interval: deviceInfo.deviceType watch ? 10000 : 5000, // 手表定位间隔 longer distance: 10, scenario: geoLocationManager.LocationScenario.NAVIGATION }; }三、整合三大服务位置提醒 APP 完整实现1. 项目核心流程应用启动获取设备信息适配 UI 布局和定位策略权限申请批量申请通知权限和定位权限设置目标用户输入或选择目标位置经纬度定位监听启动持续定位实时计算与目标位置的距离提醒触发到达目标区域发送通知并停止定位点击跳转用户点击通知进入应用查看详情。2. 完整代码实现1全局工具类整合utils/SystemServiceUtil.ets// 整合前两篇的通知、定位工具方法加上设备信息方法 import abilityAccessCtrl from ohos.abilityAccessCtrl; import notification from ohos.notification; import wantAgent from ohos.wantAgent; import geoLocationManager from ohos.geolocation; import deviceInfo from ohos.deviceInfo; import screen from ohos.screen; import common from ohos.app.ability.common; // 权限申请批量申请通知和定位权限 export async function requestAllPermissions(context: common.UIAbilityContext): Promiseboolean { const permissions [ ohos.permission.NOTIFICATION_CONTROLLER, ohos.permission.APPROXIMATELY_LOCATION, ohos.permission.LOCATION ]; const atManager abilityAccessCtrl.createAtManager(); try { const authResults await atManager.checkAccessToken( abilityAccessCtrl.createTokenID(), permissions ); const needReqPerms permissions.filter( (perm, index) authResults[index] ! abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ); if (needReqPerms.length 0) return true; const reqResult await atManager.requestPermissionsFromUser(context, needReqPerms); return reqResult.authResults.every(status status 0); } catch (err) { console.error(批量权限申请失败${JSON.stringify(err)}); return false; } } // 设备信息方法同上篇 export function getDeviceBaseInfo() { /* 省略复用前文代码 */ } export function getScreenInfo() { /* 省略复用前文代码 */ } export function getLocationConfigByDeviceType() { /* 省略复用前文代码 */ } // 通知方法同上篇 export async function createLocationReminderNotification() { /* 省略复用前文代码 */ } export async function sendNotification() { /* 省略复用前文代码 */ } // 定位方法同上篇 export function startContinuousLocation() { /* 省略复用前文代码 */ } export function stopContinuousLocation() { /* 省略复用前文代码 */ } export function isReachTargetArea() { /* 省略复用前文代码 */ }2主页面实现pages/LocationReminderPage.etsimport common from ohos.app.ability.common; import { requestAllPermissions, getDeviceBaseInfo, getScreenInfo, getLocationConfigByDeviceType, createLocationReminderNotification, sendNotification, startContinuousLocation, stopContinuousLocation, isReachTargetArea } from ../utils/SystemServiceUtil; Entry Component struct LocationReminderPage { private context getContext(this) as common.UIAbilityContext; State deviceInfoStr: string ; State currentLocation: string 未获取位置; State targetLat: string 39.9042; // 目标纬度默认值 State targetLng: string 116.4074; // 目标经度默认值 State reminderRadius: number 100; // 提醒半径米 State isTracking: boolean false; // 页面加载时获取设备信息 aboutToAppear() { this.loadDeviceInfo(); } // 加载设备信息 loadDeviceInfo() { const deviceInfo getDeviceBaseInfo(); const screenInfo getScreenInfo(); this.deviceInfoStr 设备${deviceInfo.manufacturer} ${deviceInfo.deviceModel} | 系统${deviceInfo.osVersion} | 屏幕${screenInfo.screenWidth}x${screenInfo.screenHeight}; } // 启动位置提醒 async startReminder() { // 1. 检查权限 const allGranted await requestAllPermissions(this.context); if (!allGranted) { Toast.show({ message: 部分权限未授予无法启动提醒 }); return; } // 2. 验证目标位置 const targetLoc { latitude: parseFloat(this.targetLat), longitude: parseFloat(this.targetLng) }; if (isNaN(targetLoc.latitude) || isNaN(targetLoc.longitude)) { Toast.show({ message: 目标位置格式错误 }); return; } // 3. 启动持续定位根据设备类型适配配置 this.isTracking true; Toast.show({ message: 位置提醒已启动正在跟踪您的位置 }); startContinuousLocation((currentLoc) { this.currentLocation 当前纬度${currentLoc.latitude.toFixed(6)}经度${currentLoc.longitude.toFixed(6)}; // 4. 判断是否到达目标区域 if (isReachTargetArea(currentLoc, targetLoc, this.reminderRadius)) { this.sendReminderNotification(); this.stopReminder(); } }, getLocationConfigByDeviceType()); } // 发送提醒通知 async sendReminderNotification() { const notification await createLocationReminderNotification( this.context, 位置提醒, 您已到达目标区域半径${this.reminderRadius}米点击查看详情 ); await sendNotification(notification); } // 停止位置提醒 stopReminder() { stopContinuousLocation(); this.isTracking false; Toast.show({ message: 位置提醒已停止 }); } build() { Column({ space: 25 }) .width(100%) .height(100%) .padding(30) .backgroundColor(#f5f5f5) { // 标题区域 Text(位置提醒APP) .fontSize(36) .fontWeight(FontWeight.Bold) .textAlign(TextAlign.Center) .width(100%) // 设备信息区域 Text(this.deviceInfoStr) .fontSize(16) .color(#666) .textAlign(TextAlign.Center) .width(100%) .lineHeight(24) // 目标位置输入区域 Column({ space: 15 }) .width(100%) .padding(20) .backgroundColor(#ffffff) .borderRadius(12) { Text(目标位置设置) .fontSize(20) .fontWeight(FontWeight.Medium) Row({ space: 10 }) .width(100%) { Text(纬度) .fontSize(18) .width(20%) TextInput({ text: this.targetLat }) .width(80%) .height(45) .padding(10) .border({ width: 1, color: #eee }) .borderRadius(8) .fontSize(18) .onChange((value) this.targetLat value) } Row({ space: 10 }) .width(100%) { Text(经度) .fontSize(18) .width(20%) TextInput({ text: this.targetLng }) .width(80%) .height(45) .padding(10) .border({ width: 1, color: #eee }) .borderRadius(8) .fontSize(18) .onChange((value) this.targetLng value) } Row({ space: 10 }) .width(100%) { Text(提醒半径) .fontSize(18) .width(30%) TextInput({ text: this.reminderRadius.toString() }) .width(70%) .height(45) .padding(10) .border({ width: 1, color: #eee }) .borderRadius(8) .fontSize(18) .onChange((value) this.reminderRadius parseInt(value) || 100) Text(米) .fontSize(18) .marginLeft(10) } } // 当前位置显示 Text(this.currentLocation) .fontSize(18) .width(100%) .textAlign(TextAlign.Center) .padding(15) .backgroundColor(#ffffff) .borderRadius(12) // 操作按钮区域 Row({ space: 30 }) .width(100%) .justifyContent(FlexAlign.Center) { Button(this.isTracking ? 停止提醒 : 启动提醒) .type(ButtonType.Capsule) .width(200) .height(60) .fontSize(20) .backgroundColor(this.isTracking ? #ff4d4f : #2f54eb) .onClick(() { if (this.isTracking) { this.stopReminder(); } else { this.startReminder(); } }) } } } }3配置文件完善module.json5{ module: { package: com.example.locationreminder, name: LocationReminder, mainAbility: MainAbility, requestPermissions: [ { name: ohos.permission.NOTIFICATION_CONTROLLER, reason: 用于发送位置到达提醒通知, usedScene: { abilities: [MainAbility], when: always } }, { name: ohos.permission.APPROXIMATELY_LOCATION, reason: 用于获取大致位置提供位置提醒服务, usedScene: { abilities: [MainAbility], when: inuse } }, { name: ohos.permission.LOCATION, reason: 用于获取精准位置提升提醒准确性, usedScene: { abilities: [MainAbility], when: inuse } } ], abilities: [ { name: .MainAbility, type: page, visible: true, skills: [ { entities: [entity.system.home], actions: [action.system.home] } ] } ] } }四、APP 核心功能说明1. 设备适配能力自动识别设备类型手机 / 平板 / 手表调整定位策略根据屏幕尺寸自适应 UI 布局在不同设备上显示正常适配不同 API 版本避免因系统版本差异导致功能异常。2. 合规性保障批量申请权限明确告知用户权限用途定位和通知功能可手动启停用户可控到达目标后自动停止定位降低功耗符合系统规范。3. 用户体验优化实时显示当前位置和设备信息状态透明支持自定义目标位置和提醒半径灵活适配不同场景通知点击跳转应用形成功能闭环。加入班级学习鸿蒙开发
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

太原那有网站设计公司wordpress 文章 排序

Linly-Talker可定制化方案:品牌专属数字人形象设计流程 在电商直播间里,一个穿着企业制服、声音亲切的虚拟主播正流畅地介绍新品;在教育平台上,一位由教师照片生成的“AI讲师”正在逐字讲解数学题;在银行客服界面中&am…

张小明 2025/12/25 3:48:40 网站建设

做照片书的模板下载网站做网站 赚钱

BongoCat智能窗口管理:让可爱猫咪随叫随到的完整指南 【免费下载链接】BongoCat 让呆萌可爱的 Bongo Cat 陪伴你的键盘敲击与鼠标操作,每一次输入都充满趣味与活力! 项目地址: https://gitcode.com/gh_mirrors/bong/BongoCat 你是否希…

张小明 2025/12/25 3:46:39 网站建设

老师找学生做网站是什么心态wordpress登陆后查看

Excalidraw音乐创作灵感板:旋律节奏布局 在一次远程音乐协作会议中,两位制作人和一位词作者围坐在各自的屏幕前。主创哼唱了一段新歌的结构:“前奏进来要安静,然后主歌铺垫情绪,预副歌拉起来,副歌炸开——…

张小明 2025/12/26 17:35:23 网站建设

做网站到底要不要营业执照深圳建站公司一般需要多久

Excalidraw专利说明书附图:技术方案表达 在撰写专利说明书时,如何让抽象的技术构思“被看见”,是一道长期困扰发明人与专利代理人的难题。传统的制图工具虽然精确,但往往显得冰冷、僵硬,像是在完成机械任务而非表达创造…

张小明 2025/12/26 13:35:16 网站建设

中国国家城乡建设部网站wordpress主页修改

快速体验 打开 InsCode(快马)平台 https://www.inscode.net输入框内输入如下内容: 生成一个性能对比测试项目:1) 传统方式手动编写的Flask博客系统 2) AI生成的同等功能Flask博客系统。两者都包含用户管理、文章发布、评论功能。输出两者的代码行数对比…

张小明 2025/12/26 12:34:36 网站建设

wordpress网站标题自定义财经公关公司排名

文章目录具体实现截图主要技术与实现手段关于我本系统开发思路java类核心代码部分展示结论源码lw获取/同行可拿货,招校园代理 :文章底部获取博主联系方式!具体实现截图 同行可拿货,招校园代理 java快递管理系统springboot-vue 主要技术与实现手段…

张小明 2025/12/27 3:34:00 网站建设