cocosCreator获取手机剪切板内容

最近游戏中需要加上复制粘贴的功能,这个时候就涉及到安卓原生层的东西。步骤如下:

复制功能

ts代码

调用代码,在需要复制的地方调用即可。

     public static copyToClipBoard(str) {
   
          if (sys.platform == sys.Platform.ANDROID) {
   
               PlatformMgr.callNativeFn("copyToClipboard", str);
          }
     }
    static async callNativeFn(funcName: string, jsonMsg?: string): Promise<{
    msg: string, isSucc: boolean }> {
   
        if (sys.platform != sys.Platform.ANDROID) // TODO: web 暂时只支持 Android 调用
            return

        let fn = PlatformMgr.Ins._platformIns[funcName]
        if (typeof (fn) == "function") {
    // 支持重写方法
            return await fn(funcName, jsonMsg)
        } else {
   
            return await PlatformMgr.Ins._platformIns.callNativeFn(funcName, js

相关推荐

  1. cocosCreator获取手机剪切内容

    2024-06-17 20:50:04       8 阅读
  2. Python 处理剪切内容,加载网址

    2024-06-17 20:50:04       36 阅读
  3. Android APP 剪切应用

    2024-06-17 20:50:04       8 阅读
  4. uniapp-获取手机型号

    2024-06-17 20:50:04       39 阅读
  5. android 获取手机号码

    2024-06-17 20:50:04       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-17 20:50:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-17 20:50:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-17 20:50:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-17 20:50:04       20 阅读

热门阅读

  1. python 多线程

    2024-06-17 20:50:04       10 阅读
  2. C++之std::lock_guard和std::unique_lock

    2024-06-17 20:50:04       9 阅读
  3. 异常类型处理 3.0

    2024-06-17 20:50:04       8 阅读
  4. Docker学习

    2024-06-17 20:50:04       6 阅读
  5. 【力扣】目标和

    2024-06-17 20:50:04       7 阅读
  6. 从0到1实现YOLOv3

    2024-06-17 20:50:04       7 阅读