Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeError: 对象 floaty 不存在方法 checkPermission. #47

Closed
dqss opened this issue Apr 13, 2023 · 6 comments
Closed

[TypeError: 对象 floaty 不存在方法 checkPermission. #47

dqss opened this issue Apr 13, 2023 · 6 comments
Labels
Glitch ☂️ 小问题 Usually an issue easy to resolve Settled 🌴 完成 Happy ending for both human beings and issues themselves

Comments

@dqss
Copy link

dqss commented Apr 13, 2023

No description provided.

@SuperMonster003
Copy link
Owner

floaty.checkPermission 可能源自其他 Auto.js 版本的封装方法.

AutoJs6 v6.3.0 增加了 floaty.hasPermission / floaty.requestPermission 方法用于获取 "显示在其他应用上层" 权限授予状态及权限请求.

@SuperMonster003 SuperMonster003 added Feedback Awaited 🕒 等待反馈 Waiting for the feedback from issue creater and issue will be closed if duration is over one month Glitch ☂️ 小问题 Usually an issue easy to resolve labels Apr 30, 2023
@SuperMonster003 SuperMonster003 added Stale 🕳️ 远古 Issue creater doesn't provide more specific information within a long time (often one month) and removed Feedback Awaited 🕒 等待反馈 Waiting for the feedback from issue creater and issue will be closed if duration is over one month labels May 26, 2023
@hduwhyso
Copy link

为啥不和原作者一样啊,用floaty.requestPermission。这样软件适配会好点

@SuperMonster003
Copy link
Owner

@hduwhyso floaty.requestPermission 已经可用.

@SuperMonster003 SuperMonster003 added Settled 🌴 完成 Happy ending for both human beings and issues themselves and removed Stale 🕳️ 远古 Issue creater doesn't provide more specific information within a long time (often one month) labels Nov 3, 2023
@hduwhyso
Copy link

hduwhyso commented Nov 4, 2023

@hduwhyso floaty.requestPermission 已经可用.

6.4.1还是提示不存在方法checkPermission。floaty.checkPermission()这个命令用不了

@hduwhyso
Copy link

hduwhyso commented Nov 4, 2023

目前AJ6的方法是floaty.hasPermission();能不能和原版一样,也用floaty.checkPermission()这个方法。

@SuperMonster003
Copy link
Owner

@hduwhyso

AutoJs6 将继续保持 floaty.hasPermission 方法用于检查权限, 未来 checkPermission 将返回权限状态常量值.

按照 Android 的多数方法签名规律, 总结权限相关的方法如下.

  • checkPermission / checkSelfPermission

    • 用于检查权限, 返回权限的状态常量值, 如 android.content.pm.PackageManager.PERMISSION_DENIEDandroid.content.pm.PackageManager.PERMISSION_GRANTED 等.
  • hasPermission

    • 用于判断是否被授予权限, 使用的一般是 checkPermission() == android.content.pm.PackageManager.PERMISSION_GRANTED 判断方法.

另外还有几个 AutoJs6 常用的权限相关的方法

  • requestPermission

    • 申请权限.
  • revokePermission

    • 撤销权限.
  • ensurePermission

    • 确保权限授予, 否则将抛出异常.

AutoJs6 将尽量保证与 Auto.js 4.x 保持 API 的一致, 但为了更贴近方法名称的语义, checkPermission 将与原有 API 存在出入.

如果需要兼容其他版本 Auto.js, 可使用类似以下条件语句:

let hasFloatyPermission = context.packageName.includes('autojs6')
    ? floaty.hasPermission()
    : floaty.checkPermission();
console.log(hasFloatyPermission);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Glitch ☂️ 小问题 Usually an issue easy to resolve Settled 🌴 完成 Happy ending for both human beings and issues themselves
Projects
None yet
Development

No branches or pull requests

3 participants