diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts index 21fa0d5c1779a02d3a76950e3e2eec5abde30654..b6501046948bc70f2a5561d358dc9e343a3b8634 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