diff --git a/pages/lifecycle/lifecycle.vue b/pages/lifecycle/lifecycle.vue
index 1d6a8419a2c19c0cd92c5293b6764537c9f14c03..e0e9723578448790fb0a66e1cc9af07da930aaa6 100644
--- a/pages/lifecycle/lifecycle.vue
+++ b/pages/lifecycle/lifecycle.vue
@@ -2,6 +2,8 @@
+
+
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
@@ -18,12 +20,13 @@
diff --git a/pages/resource/resource.vue b/pages/resource/resource.vue
index 2ffefabad51509f79c6122687275fa8bf5326e15..4703ffb6794f0da9ff7f75b432f891193d174401 100644
--- a/pages/resource/resource.vue
+++ b/pages/resource/resource.vue
@@ -1,15 +1,13 @@
-
-
-
-
+
+
diff --git a/uni_modules/uts-advance/utssdk/app-android/index.uts b/uni_modules/uts-advance/utssdk/app-android/index.uts
index 38cad64093376ad7fec88086adcf18a41943bb26..7b0cf36c967ba1cb013bd78df0f241246691249a 100644
--- a/uni_modules/uts-advance/utssdk/app-android/index.uts
+++ b/uni_modules/uts-advance/utssdk/app-android/index.uts
@@ -5,15 +5,28 @@ import ViewGroup from "android.view.ViewGroup";
import Gravity from "android.view.Gravity";
import Runnable from 'java.lang.Runnable';
import MediaPlayer from 'android.media.MediaPlayer';
+import Log from 'android.util.Log';
+import Intent from 'android.content.Intent';
import logo from "../../static/logo.png";
import PackageManager from "android.content.pm.PackageManager";
+import MediaStore from "android.provider.MediaStore";
+import Bundle from "android.os.Bundle";
+import ActivityCompat from "androidx.core.app.ActivityCompat";
+import Manifest from "android.Manifest";
+import Activity from "android.app.Activity";
+import Bitmap from "android.graphics.Bitmap";
+import FileOutputStream from "java.io.FileOutputStream";
import {
onAppActivityDestroy,
onAppActivityPause,
onAppActivityResume,
onAppActivityBack,
+ onAppActivityStop,
+ onAppActivityResult,
+ onAppTrimMemory,
+ onAppConfigChange,
getUniActivity,
getAppContext
} from "io.dcloud.uts.android";
@@ -179,7 +192,44 @@ export function playAssetAudio() {
}
-
+export function goOtherActivity(imageDone: (event:string) => void):boolean {
+
+ // 检查相关权限是否已经具备
+ if (ActivityCompat.checkSelfPermission(getUniActivity()!, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
+ // 不具备权限,申请权限,并且告知用户监听失败
+ ActivityCompat.requestPermissions(getUniActivity()!, arrayOf(Manifest.permission.CAMERA), 1002)
+
+ return false;
+ }
+
+ onAppActivityResult((requestCode: Int, resultCode: Int, data?: Intent) => {
+ let eventName = "onAppActivityResult - requestCode:" + requestCode + " -resultCode:"+resultCode + " -data:"+JSON.stringify(data);
+ console.log(eventName);
+ if ((requestCode == 1001) && (resultCode == Activity.RESULT_OK)) {
+ if (data != null) {
+ let bundle = data.getExtras();
+ let mImageBitmap = bundle!.get("data") as Bitmap;
+ let bitmapPath = getUniActivity()!.getExternalCacheDir()!.getPath() + "/photo.png"
+ console.log(bitmapPath);
+ try{
+ mImageBitmap.compress(Bitmap.CompressFormat.PNG,100,new FileOutputStream(bitmapPath))
+ }catch(e){
+ }
+ imageDone(bitmapPath);
+
+ }
+ }
+ });
+
+ let takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ //resolveActivity 返回可处理 Intent 的第一个 Activity 组件
+ if (takePictureIntent.resolveActivity(getUniActivity()!.getPackageManager()) != null) {
+ getUniActivity()!.startActivityForResult(takePictureIntent, 1001);
+ }
+
+ return true;
+
+}
/**
@@ -188,21 +238,40 @@ export function playAssetAudio() {
*/
export function initAppLifecycle(onLifecycleChange: (event:string) => void) {
+
+
+ onAppTrimMemory((level:Number) => {
+ let eventName = "onAppTrimMemory - " + level;
+ onLifecycleChange(eventName);
+ console.log(eventName);
+ });
+
+
+ onAppConfigChange((ret:UTSJSONObject) => {
+ let eventName = "onAppConfigChange - " + JSON.stringify(ret);
+ onLifecycleChange(eventName);
+ console.log(eventName);
+ });
+
+
/**
* activity 销毁生命周期回调
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitydestroy
*/
onAppActivityDestroy(() => {
- let eventName = "onAppActivityDestroy - " + Date.now();
+ let eventName = "onAppActivityDestroy";
onLifecycleChange(eventName);
console.log(eventName);
});
+
+
+
/**
* activity 失去焦点生命周期回调
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitypause
*/
onAppActivityPause(() => {
- let eventName = "onAppActivityPause - " + Date.now();
+ let eventName = "onAppActivityPause" ;
onLifecycleChange(eventName);
console.log(eventName);
});
@@ -211,7 +280,7 @@ export function initAppLifecycle(onLifecycleChange: (event:string) => void) {
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivityresume
*/
onAppActivityResume(() => {
- let eventName = "onAppActivityResume - " + Date.now();
+ let eventName = "onAppActivityResume";
onLifecycleChange(eventName);
console.log(eventName);
});
@@ -220,7 +289,7 @@ export function initAppLifecycle(onLifecycleChange: (event:string) => void) {
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivityback
*/
onAppActivityBack(() => {
- let eventName = "onAppActivityBack - " + Date.now();
+ let eventName = "onAppActivityBack";
onLifecycleChange(eventName);
console.log(eventName);
});
diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts
index 89109f2dabe3c2268966ddb1c1a5eadf4dccf2b6..c9e2bdc75addbfbba64cd2671d37a0a8d29b0452 100644
--- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts
+++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts
@@ -40,7 +40,7 @@ class ForeService extends Service {
}
- override onBind(intent?: Intent): IBinder|null{
+ override onBind(_intent?: Intent): IBinder|null{
return null;
}
@@ -98,7 +98,7 @@ class ScreenReceiver extends BroadcastReceiver{
super();
}
- override onReceive(context: Context, intent: Intent):void {
+ override onReceive(_context: Context, intent: Intent):void {
if (Intent.ACTION_SCREEN_OFF == intent.action) {
console.log("==屏幕休眠了")
}
diff --git a/uni_modules/uts-toast/utssdk/app-android/config.json b/uni_modules/uts-toast/utssdk/app-android/config.json
deleted file mode 100644
index 68231cf6c67064044958eaa644ba8af51cb5c8d6..0000000000000000000000000000000000000000
--- a/uni_modules/uts-toast/utssdk/app-android/config.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "abis": [
- "arm64-v8a"
- ],
- "minSdkVersion": 21
-}
-
diff --git a/uni_modules/uts-toast/utssdk/app-android/index.uts b/uni_modules/uts-toast/utssdk/app-android/index.uts
index 472deed46d3fe61d13400505a1e9cd71f463243e..26c44ff167064a96d70310a02a461dd37aedecac 100644
--- a/uni_modules/uts-toast/utssdk/app-android/index.uts
+++ b/uni_modules/uts-toast/utssdk/app-android/index.uts
@@ -5,21 +5,14 @@ import {
import XToast from "com.hjq.xtoast.XToast";
import R from "io.dcloud.uni_modules.uts_toast.R";
-export function getLogoPath():string{
+export function showToast():string{
- // new XToast(getUniActivity())
- // .setDuration(1000)
- // .setContentView(R.layout.window_hint)
- // .setImageDrawable(android.R.id.icon, android.R.mipmap.sym_def_app_icon)
- // .setText(android.R.id.message, "一秒后自动消失")
- // .show();
-
- XToast>(getUniActivity())
+ new XToast>(getUniActivity())
.setDuration(1000)
.setContentView(R.layout.window_hint)
.setImageDrawable(android.R.id.icon, android.R.mipmap.sym_def_app_icon)
.setText(android.R.id.message, "一秒后自动消失")
.show()
- return "hello toast"
+ return ""
}
\ No newline at end of file