From 79887d56357286820439963d8ec48aa5f6426d5a Mon Sep 17 00:00:00 2001 From: duqingquan Date: Tue, 2 Jul 2024 16:56:47 +0800 Subject: [PATCH] =?UTF-8?q?hello=20uts=20native-page=20=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Handler=20=E4=BD=BF=E7=94=A8=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utssdk/app-android/index.uts | 81 ++++++++++++------- uni_modules/uts-tests/utssdk/Date.uts | 20 +++-- 2 files changed, 63 insertions(+), 38 deletions(-) diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts index 21fa0d5..b650104 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts +++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts @@ -61,6 +61,9 @@ export function sayHelloFromJar(): string { } + + + export class AppHookProxy implements UTSAndroidHookProxy { override onCreate(application: Application) { //当前应用是否 取得用户同意隐私协议 @@ -162,13 +165,13 @@ class StartServiceListener extends OnClickListener{ override onClick(v?: View):void{ - var intent = new Intent(UTSAndroid.getUniActivity(), ForeService().javaClass); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - UTSAndroid.getAppContext()!.startForegroundService(intent); - } - else{ - UTSAndroid.getAppContext()!.startService(intent); - } + var intent = new Intent(UTSAndroid.getUniActivity(), ForeService().javaClass); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + UTSAndroid.getAppContext()!.startForegroundService(intent); + } + else{ + UTSAndroid.getAppContext()!.startService(intent); + } } } @@ -308,40 +311,56 @@ class FruitAdapter extends RecyclerView.Adapter{ } +@Suppress("DEPRECATION") class DemoActivity extends Activity{ constructor (){ super(); } + // 自定义 handler + CustomHandler = class extends android.os.Handler { + constructor (){ + super(); + } + override handleMessage(msg: android.os.Message) { + super.handleMessage(msg) + if(msg.what = 111){ + console.log("handle message received:111") + } + } + } override onCreate(savedInstanceState?: Bundle):void { super.onCreate(savedInstanceState) this.setContentView(R.layout.demo_activity); - let btn_start_service_front = this.findViewById