Git Product home page Git Product logo

Comments (6)

SuperMonster003 avatar SuperMonster003 commented on August 21, 2024

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

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

from autojs6.

hduwhyso avatar hduwhyso commented on August 21, 2024

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

from autojs6.

SuperMonster003 avatar SuperMonster003 commented on August 21, 2024

@hduwhyso floaty.requestPermission 已经可用.

from autojs6.

hduwhyso avatar hduwhyso commented on August 21, 2024

@hduwhyso floaty.requestPermission 已经可用.

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

from autojs6.

hduwhyso avatar hduwhyso commented on August 21, 2024

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

from autojs6.

SuperMonster003 avatar SuperMonster003 commented on August 21, 2024

@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);

from autojs6.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.