提交 b7bb6c88 编写于 作者: 杜庆泉's avatar 杜庆泉

修复 截屏监听 android 6.0 一下不能使用的Bug

上级 073c7f23
...@@ -9,6 +9,7 @@ import Environment from "android.os.Environment"; ...@@ -9,6 +9,7 @@ import Environment from "android.os.Environment";
import System from 'java.lang.System'; import System from 'java.lang.System';
import WindowManager from 'android.view.WindowManager'; import WindowManager from 'android.view.WindowManager';
import { OnUserCaptureScreenCallbackResult, UserCaptureScreenCallback, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreenSuccess, SetUserCaptureScreenOptions, SetUserCaptureScreen } from "../interface.uts"; import { OnUserCaptureScreenCallbackResult, UserCaptureScreenCallback, OnUserCaptureScreen, OffUserCaptureScreen, SetUserCaptureScreenSuccess, SetUserCaptureScreenOptions, SetUserCaptureScreen } from "../interface.uts";
import string from 'android.R.string';
/** /**
...@@ -34,9 +35,9 @@ class ScreenFileObserver extends FileObserver { ...@@ -34,9 +35,9 @@ class ScreenFileObserver extends FileObserver {
*/ */
private screenFile : File; private screenFile : File;
constructor(screenFile : File) { constructor(screenFileStr : string) {
super(screenFile); super(screenFileStr);
this.screenFile = screenFile; this.screenFile = new File(screenFileStr);
} }
override onEvent(event : Int, path : string | null) : void { override onEvent(event : Int, path : string | null) : void {
...@@ -83,7 +84,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us ...@@ -83,7 +84,7 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
} }
// 先结束监听 再开启监听 // 先结束监听 再开启监听
observer?.stopWatching(); observer?.stopWatching();
observer = new ScreenFileObserver(directory_screenshot); observer = new ScreenFileObserver(directory_screenshot.getPath());
observer?.startWatching(); observer?.startWatching();
...@@ -92,7 +93,6 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us ...@@ -92,7 +93,6 @@ export const onUserCaptureScreen : OnUserCaptureScreen = function (callback : Us
observer = null observer = null
}) })
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册