# UTSAndroid app-android平台专有内置对象。在uni-app和uni-app x的uts环境中均可使用。 ## 静态方法 ### onAppConfigChange(callback) ### offAppConfigChange(callback?) ### onAppTrimMemory(callback?) ### offAppTrimMemory(callback?) ### onAppActivityPause(callback) ### offAppActivityPause(callback?) ### onAppActivityResume(callback) ### offAppActivityResume(callback?) ### onAppActivityDestroy(callback) ### offAppActivityDestroy(callback?) ### onAppActivityResult(callback) ### offAppActivityResult(callback?) ### onAppActivityBack(callback) ### offAppActivityBack(callback?) ### getAppContext() ### getUniActivity() ### getResourcePath(resourceName) ### exit() ### getDispatcher(threadName) ```uts // 不传任何参数,得到是当前代码运行线程 let currentDispatcher = UTSAndroid.getDispatcher() console.log("currentDispatcher",currentDispatcher) // 期望在 io 任务队列执行 UTSAndroid.getDispatcher("io").async(function(_){ console.log("当前任务执行在",Thread.currentThread().getName()) // 期望在 主线程 任务队列执行 UTSAndroid.getDispatcher("main").async(function(_){ console.log("当前任务执行在",Thread.currentThread().getName()) currentDispatcher.async(function(_){ console.log("起始任务执行在",Thread.currentThread().getName()) },null) },null) },null) ``` ### getAppId() ### getOsTheme() ### isUniMp() ### getAppName() ### getAppVersion() ### getInnerVersion() ### isUniAppX() ### getAppCachePath * 如果编译报错找不到该方法,手动删除“uniapp-runextension”插件重新安装 或者 重新下载安装最新版本 HBuilder X 即可修复* ### rpx2px(rpx:number) : number; ### devicePX2px(devicePX:number) : number; ### isPrivacyAgree() : boolean; ### setPrivacyAgree(state:boolean):void; ### resetPrivacyAgree():void; ### requestSystemPermission ### checkSystemPermissionGranted ### gotoSystemPermissionActivity ### getSystemPermissionDenied ### convert2AbsFullPath ### getFileProviderUri ```ts // 使用外部应用打开项目内置图片资源 let file = new File(UTSAndroid.getResourcePath("static/logo.png")) const uri = UTSAndroid.getFileProviderUri(file) const intent = new Intent(Intent.ACTION_VIEW, uri) intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) const context = UTSAndroid.getUniActivity()!; context.startActivity(intent); ```