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

lifecycle 增加取消生命周期监听

上级 fb9727b9
......@@ -4,6 +4,7 @@
<page-head :title="title"></page-head>
<button @tap="testGoOtherActivity">跳转选择界面</button>
<image :src="selectImage" v-if="selectImage"></image>
<button @tap="testUnRegLifecycle">取消注册周期函数</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
......@@ -20,7 +21,7 @@
</view>
</template>
<script>
import { initAppLifecycle,goOtherActivity } from '../../uni_modules/uts-advance';
import { initAppLifecycle,unRegLifecycle,goOtherActivity } from '../../uni_modules/uts-advance';
export default {
data() {
return {
......@@ -52,6 +53,10 @@
title:'请授予权限后重试'
})
}
},
testUnRegLifecycle(){
// 取消注册生命周期
unRegLifecycle();
}
}
}
......
......@@ -21,16 +21,21 @@ import Toast from 'android.widget.Toast';
import AlertDialog from 'android.app.AlertDialog';
import DialogInterface from 'android.content.DialogInterface';
import EditText from 'android.widget.EditText';
import R from 'io.dcloud.uni_modules.uts_advance.R';
import {
onAppActivityDestroy,
offAppActivityDestroy,
onAppActivityPause,
offAppActivityPause,
onAppActivityResume,
offAppActivityResume,
onAppActivityBack,
offAppActivityBack,
onAppActivityResult,
onAppTrimMemory,
offAppTrimMemory,
onAppConfigChange,
offAppConfigChange,
getUniActivity,
getAppContext
} from "io.dcloud.uts.android";
......@@ -391,3 +396,40 @@ export function initAppLifecycle(onLifecycleChange: (event:string) => void) {
}
/**
* 取消注册生命周期函数
*/
export function unRegLifecycle() {
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onapptrimmemory
*/
offAppTrimMemory();
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onAppConfigChange
*/
offAppConfigChange();
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitydestroy
*/
offAppActivityDestroy();
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivitypause
*/
offAppActivityPause();
/**
* 说明文档:https://uniapp.dcloud.net.cn/plugin/uts-plugin.html#onappactivityresume
*/
offAppActivityResume();
/**
* activity 回退物理按键事件回调
*/
offAppActivityBack();
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册