AppState使用

import React, { Component } from 'react';
import {AppRegistry,StyleSheet,Text,View,AppState} from 'react-native'; export default class AppStateApiView extends Component { componentWillUnmount() {
AppState.removeEventListener('change', this.handleAppStateChange);
} componentWillMount() {
AppState.addEventListener('change', this.handleAppStateChange);
AppState.addEventListener('memoryWarning', function(){
console.log("内存报警....");
});
} //状态改变响应
handleAppStateChange(appState) {
alert('当前状态为:'+appState);
//active前台运行中 background后台运行中 inactive运行的过渡状态
} render() {
return (
<View style={styles.container}>
<Text style={styles.styleText}>
状态监听中:
</Text>
</View>
);
}
} const styles = StyleSheet.create({
container:{
flex: 1,
marginTop:25
},
styleText:{
marginTop:10,
textAlign:'center'
},
styleAppState:{
marginTop:10,
color:'red',
textAlign:'center'
},
});

AppState使用的更多相关文章

  1. Appstate的几种状态及在android 和ios触发

    AppState能告诉你当前应用是在前台还是在后台,或者处于切换应用的状态,并且能在状态变化的时候通知你. AppState 通常在处理推送通知的时候用来决定内容和对应的行为 一: App State ...

  2. cshtml 中的 AppState = Context.Application 和 控制器中的 Application 也相等

    AppState = Context.Application @{ ViewBag.Title = "Home Page"; AppState["s1"] = ...

  3. ReactNative入门(安卓)——API(上)

    Alert - 弹窗 通过 Alert.alert() 方法调用唤起原生弹窗,点击会触发 onPress 回调(参考下方代码)并清除弹窗. import React, { AppRegistry, C ...

  4. android intent 传递list或者对象

    (转:http://www.cnblogs.com/lee0oo0/archive/2012/09/24/2699805.html) 方法一: 如果单纯的传递List<String> 或者 ...

  5. ReactNative官方中文文档0.21

    整理了一份ReactNative0.21中文文档,提供给需要的reactnative爱好者.ReactNative0.21中文文档.chm  百度盘下载:ReactNative0.21中文文档 来源: ...

  6. Asp.Net MVC<八>:View的呈现

    ActionResult 原则上任何类型的响应都可以利用当前的HttpResponse来完成.但是MVC中我们一般将针对请求的响应实现在一个ActionResult对象中. public abstra ...

  7. Intent之复杂数据的传递

    想在两个Activity之间传递一个对象Result,在网上差了很多,都需要序列化或者时下Paracelable,等等,试了很多都不行. 后来才制单,这个Result,根本不需要集成Sereriabl ...

  8. Google V8编程详解(五)JS调用C++

    http://blog.csdn.net/feiyinzilgd/article/details/8453230 最近由于忙着解决个人单身的问题,时隔这么久才更新第五章. 上一章主要讲了Google ...

  9. Android 7.0 UICC 分析(四)

    本文讲解SIMRecords /frameworks/opt/telephony/src/java/com/android/internal/telephony/uicc/SIMRecords.jav ...

随机推荐

  1. [Hinton] Neural Networks for Machine Learning - Hopfield Nets and Boltzmann Machine

    Lecture 11 — Hopfield Nets Lecture 12 — Boltzmann machine learning Ref: 能量模型(EBM).限制波尔兹曼机(RBM) 高大上的模 ...

  2. Tomcat启动报Error listenerStart错误 Context [] startup failed due to previous errors

    本文转载自xpenxpen 今天启动Tomcat启动不了,报以下错: org.apache.catalina.core.StandardContext startInternal SEVERE: Er ...

  3. php: Cannot send session cache limiter

    修改php.ini中的session.auto_start = 0 为 session.auto_start = 1 MAC 的php.ini 在 /private/etc/ 目录下修改的时候发现su ...

  4. super()方法

    super()是一个调用父类的方法. super()用来解决多继承问题,直接用类名调用父类的方法在单继承中是没有问题的,但是如果使用多继承会涉及到查找顺序(MRO).重复调用等种种问题. python ...

  5. TCP通信粘包问题分析和解决

    转载至https://www.cnblogs.com/kex1n/p/6502002.html 在socket网络程序中,TCP和UDP分别是面向连接和非面向连接的.因此TCP的socket编程,收发 ...

  6. linux下安装cmake(安装opencv库)

    apt-get install cmake cmake --version(显示版本号) cmake-gui(打开gui界面) 如果打不该GUI界面时候就需要apt-get install cmake ...

  7. nginx启用TCP反向代理日志配置

    Nginx使用TCP反向代理日志配置不同于http 修改nginx配置文档/usr/local/nginx/conf/nginx.conf 设置日志格式 stream { log_format pro ...

  8. 高效办公必不可少的5个Excel技巧

    1.输入“001.002…”的编号 想要快速给表格添加上“001.002…”这样的编号,你可以这样做: 选择所有单元格——右键点击[设置单元格格式]——点击[文本]——点击[确定]即可. 2.单元格内 ...

  9. asp.net Ajax调用Aspx后台方法

    Ajax调用的前提(以aspx文件为例:) 1.首先需要在aspx文件后台中引用using System.Web.Services; 2.需要调用的方法必须是公共的(public).静态的(stati ...

  10. Unable to cast object of type 'System.Int32' to type 'System.Array'.

    x 入职了新公司.最近比较忙...一看博客...更新频率明显少了...罪过罪过... 新公司用ASP.NET MVC 遇上一个错误: Unable to cast object of type 'Sy ...