AIWROK软件HID_APK插件_安卓原生调用方法
<div><span style="font-family: "Microsoft Yahei", Hei, Tahoma, SimHei, sans-serif; font-size: 22px; font-weight: 700;">AIWROK软件HID_APK插件_安卓原生调用方法</span><div><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span style="font-size: 12pt; font-family: 宋体;">本插件可以使用安卓原生开发调用<span lang="EN-US">,</span>具体方法如下<span lang="EN-US"><br>1.</span>下载<span lang="EN-US">apk</span>插件<span lang="EN-US"><br>2.</span>放到项目<span lang="EN-US">asset</span>文件夹下<span lang="EN-US"><br><img width="613" height="502" id="图片 15" src="http://www.postbbs.com/2/index.files/image001.gif" alt="https://cdn.nlark.com/yuque/0/2025/png/44811133/1749729107649-34dafe79-040b-41e7-b30c-3c45e341adeb.png" style="border-radius: 5px;"><br>3.AndroidManifest.xml</span>文件中添加权限</span></p><div style="color: rgb(0, 0, 0); font-family: "Microsoft YaHei"; font-size: medium; border: 1pt solid rgb(232, 232, 232); padding: 12pt; background: rgb(249, 249, 249);"><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.INTERNET" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.FOREGROUND_SERVICE" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><!-- </span><span style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);">声明权限<span lang="EN-US"> --></span></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BIND_WALLPAPER" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-feature android:name="android.hardware.usb.accessory" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.USB_PERMISSION" ></uses> <!-- </span><span style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);">添加<span lang="EN-US">USB</span>权限<span lang="EN-US"> --></span></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-feature android:name="android.hardware.usb.host" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><!-- Request legacy Bluetooth permissions on older devices. --></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BLUETOOTH" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BLUETOOTH_ADMIN" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><!-- Needed only if your app looks for Bluetooth devices.</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> You must add an attribute to this permission, or declare the</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> ACCESS_FINE_LOCATION permission, depending on the results when you</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> check location usage in your app. --></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BLUETOOTH_CONNECT" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BLUETOOTH_CONNECT" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BLUETOOTH_SCAN" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><!-- Needed only if your app makes the device discoverable to Bluetooth</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> devices. --></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><!-- Needed only if your app communicates with already-paired Bluetooth</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> devices. --></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BLUETOOTH_CONNECT" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" ></uses></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><uses-permission android:name="android.permission.BLUETOOTH_SCAN" ></uses></span></p></div><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span style="font-size: 12pt; font-family: 宋体;">具体说明如下:</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">1.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.INTERNET" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:声明应用需要访问互联网的权限。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">2.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.FOREGROUND_SERVICE" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用在前台运行服务。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">3.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:请求忽略电池优化的权限,以便应用在后台运行时不会被系统电池优化功能所限制。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">4.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用在其他应用的窗口之上显示系统级的窗口。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">5.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用使用内部系统窗口,通常用于创建系统级别的<span lang="EN-US">UI</span>组件,但需要注意的是,此权限并不是官方公开的权限,普通应用不建议使用,需确保其合法性。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">6.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.BIND_WALLPAPER" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用绑定为壁纸服务。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">7.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-feature android:name="android.hardware.usb.accessory" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:声明应用需要访问<span lang="EN-US">USB</span>配件的功能。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">8.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.USB_PERMISSION" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:请求<span lang="EN-US">USB</span>设备的权限。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">9.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-feature android:name="android.hardware.usb.host" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:声明应用需要作为<span lang="EN-US">USB</span>主机的功能,可以连接并控制外接<span lang="EN-US">USB</span>设备。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">10.</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.BLUETOOTH" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用进行基本的蓝牙操作。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">11.</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.BLUETOOTH_ADMIN" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用配置蓝牙设置和管理蓝牙设备。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">12.</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.BLUETOOTH_CONNECT" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用连接到蓝牙设备。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">13.</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.BLUETOOTH_SCAN" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用扫描周围的蓝牙设备。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">14.</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用使设备可被其他蓝牙设备发现。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">15.</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用访问大致位置信息,用于发现蓝牙设备。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">16.</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" ></uses></span><span style="font-size: 12pt; font-family: 宋体;">:允许应用访问精确位置信息,同样用于发现蓝牙设备。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">4.</span><span style="font-size: 12pt; font-family: 宋体;">把这个<span lang="EN-US">xml</span>文件添加到<span lang="EN-US">xml</span>文件夹中<span lang="EN-US">accessory_filter.xml</span></span></p><div style="color: rgb(0, 0, 0); font-family: "Microsoft YaHei"; font-size: medium; border: 1pt solid rgb(232, 232, 232); padding: 12pt; background: rgb(249, 249, 249);"><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><?xml version="1.0" encoding="utf-8"?></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><resources></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <usb-accessory manufacturer="aiwork" model="hid" version="2.0" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"></resources></span></p></div><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;"><img width="873" height="1030" id="图片 14" src="http://www.postbbs.com/2/index.files/image002.gif" alt="https://cdn.nlark.com/yuque/0/2025/png/44811133/1749729122306-bf034155-178d-4ca2-b776-a456d76a85b3.png" style="border-radius: 5px;"></span><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;"><br>5.</span><span style="font-size: 12pt; font-family: 宋体;">在<span lang="EN-US">AndroidManifest.xml </span>中<span lang="EN-US"> mainActivity</span>中添加以下代码</span></p><div style="color: rgb(0, 0, 0); font-family: "Microsoft YaHei"; font-size: medium; border: 1pt solid rgb(232, 232, 232); padding: 12pt; background: rgb(249, 249, 249);"><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><activity</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> android:name=".MainActivity"</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> android:exported="true"></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <action android:name="android.intent.action.MAIN" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <category android:name="android.intent.category.LAUNCHER" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <meta-data</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> android:resource="@xml/accessory_filter" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"></activity> <!-- </span><span style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);">注册<span lang="EN-US">USB</span>设备连接和断开的广播接收器<span lang="EN-US"> --></span></span></p></div><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span style="font-size: 12pt; font-family: 宋体;">具体说明如下:</span></p><div style="color: rgb(0, 0, 0); font-family: "Microsoft YaHei"; font-size: medium; border: 1pt solid rgb(232, 232, 232); padding: 12pt; background: rgb(249, 249, 249);"><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><activity</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> android:name=".MainActivity"</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> android:exported="true"></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <action android:name="android.intent.action.MAIN" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <category android:name="android.intent.category.LAUNCHER" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> </intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <meta-data</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> android:resource="@xml/accessory_filter" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"></activity></span></p></div><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">1.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><activity android:name=".MainActivity" android:exported="true"></span><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">: </span><span style="font-size: 12pt; font-family: 宋体;">声明一个名为</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">MainActivity</span><span style="font-size: 12pt; font-family: 宋体;">的活动(<span lang="EN-US">Activity</span>),</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">android:name=".MainActivity"</span><span style="font-size: 12pt; font-family: 宋体;">指定了活动的类名,</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">.MainActivity</span><span style="font-size: 12pt; font-family: 宋体;">表示该活动位于应用的根包中。</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">android:exported="true"</span><span style="font-size: 12pt; font-family: 宋体;">表示该活动可以被其他应用启动。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">2.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><intent-filter></span><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">: </span><span style="font-size: 12pt; font-family: 宋体;">用于定义该活动可以响应的<span lang="EN-US">Intent</span>。每个</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><intent-filter></span><span style="font-size: 12pt; font-family: 宋体;">可以包含</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><action></span><span style="font-size: 12pt; font-family: 宋体;">、</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><category></span><span style="font-size: 12pt; font-family: 宋体;">和</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><data></span><span style="font-size: 12pt; font-family: 宋体;">等子元素,用以指定活动能够处理的<span lang="EN-US">Intent</span>类型。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 10pt; font-family: "Courier New";">o<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span style="font-size: 12pt; font-family: 宋体;">第一个</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><intent-filter></span><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">:</span></p><div style="color: rgb(0, 0, 0); font-family: "Microsoft YaHei"; font-size: medium; border: 1pt solid rgb(232, 232, 232); padding: 12pt; background: rgb(249, 249, 249);"><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <action android:name="android.intent.action.MAIN" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <category android:name="android.intent.category.LAUNCHER" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"></intent-filter></span></p></div><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span style="font-size: 12pt; font-family: 宋体;">这个</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">intent-filter</span><span style="font-size: 12pt; font-family: 宋体;">定义了该活动作为应用的入口点。</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><action android:name="android.intent.action.MAIN" /></span><span style="font-size: 12pt; font-family: 宋体;">表示该活动是应用的主要活动。</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><category android:name="android.intent.category.LAUNCHER" /></span><span style="font-size: 12pt; font-family: 宋体;">表示该活动可以在应用启动器中启动,即它会出现在应用的快捷方式或图标上,让用户可以点击启动应用。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 10pt; font-family: "Courier New";">o<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span style="font-size: 12pt; font-family: 宋体;">第二个</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><intent-filter></span><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">:</span></p><div style="color: rgb(0, 0, 0); font-family: "Microsoft YaHei"; font-size: medium; border: 1pt solid rgb(232, 232, 232); padding: 12pt; background: rgb(249, 249, 249);"><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"><intent-filter></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"> <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /></span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; padding: 0cm; font-family: 等线; font-size: 10.5pt; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; border: none;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体; color: rgb(89, 89, 89);"></intent-filter></span></p></div><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;"> </span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span style="font-size: 12pt; font-family: 宋体;">这个</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">intent-filter</span><span style="font-size: 12pt; font-family: 宋体;">定义了该活动可以响应<span lang="EN-US">USB</span>配件连接的<span lang="EN-US">Intent</span>。</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" /></span><span style="font-size: 12pt; font-family: 宋体;">表示该活动会在<span lang="EN-US">USB</span>配件连接到设备时被触发。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">3.<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><meta-data></span><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">: </span><span style="font-size: 12pt; font-family: 宋体;">用于为该活动提供额外的信息。在这个例子中,</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><meta-data></span><span style="font-size: 12pt; font-family: 宋体;">用于指定<span lang="EN-US">USB</span>配件的过滤器配置文件。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0); text-indent: -18pt;"><span lang="EN-US" style="font-size: 10pt; font-family: "Courier New";">o<span style="font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-alternates: normal; font-kerning: auto; font-optical-sizing: auto; font-feature-settings: normal; font-variation-settings: normal; font-stretch: normal; font-size: 7pt; line-height: normal; font-family: "Times New Roman";"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;"><meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter" /></span><span lang="EN-US" style="font-size: 12pt; font-family: 宋体;">: </span><span style="font-size: 12pt; font-family: 宋体;">这个</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">meta-data</span><span style="font-size: 12pt; font-family: 宋体;">标签指定了当<span lang="EN-US">USB</span>配件连接时,系统会根据</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">@xml/accessory_filter</span><span style="font-size: 12pt; font-family: 宋体;">文件中的配置来决定是否将该<span lang="EN-US">Intent</span>发送给</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">MainActivity</span><span style="font-size: 12pt; font-family: 宋体;">。</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">@xml/accessory_filter</span><span style="font-size: 12pt; font-family: 宋体;">是一个<span lang="EN-US">XML</span>资源文件,定义了应用可以兼容的<span lang="EN-US">USB</span>配件的属性(如制造商、产品<span lang="EN-US">ID</span>等),当设备检测到符合这些属性的<span lang="EN-US">USB</span>配件连接时,会将</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">USB_ACCESSORY_ATTACHED</span><span style="font-size: 12pt; font-family: 宋体;">的<span lang="EN-US">Intent</span>发送给</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">MainActivity</span><span style="font-size: 12pt; font-family: 宋体;">。</span></p><p class="MsoNormal" align="left" style="margin: 0cm 0cm 0.0001pt; font-family: 等线; font-size: 10.5pt; color: rgb(0, 0, 0);"><span style="font-size: 12pt; font-family: 宋体;">总结:这段代码声明了一个名为</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">MainActivity</span><span style="font-size: 12pt; font-family: 宋体;">的活动,并将其设置为应用的入口点,使其可以在设备的启动器中显示。此外,它还声明了</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">MainActivity</span><span style="font-size: 12pt; font-family: 宋体;">可以响应<span lang="EN-US">USB</span>配件连接的事件,并通过</span><span lang="EN-US" style="font-size: 12pt; font-family: Consolas;">meta-data</span><span style="font-size: 12pt; font-family: 宋体;">标签指定了一个<span lang="EN-US">XML</span>配置文件,用于定义应用可以兼容的<span lang="EN-US">USB</span>配件的具体属性。</span></p><div><span style="font-size: 12pt; font-family: 宋体;"><br></span></div><p style="font-family: "Lucida Grande", Geneva, Verdana, Arial; font-size: 12px;"></p></div></div>
页:
[1]