按 home 键,再打开app,会调用onNewIntent()

按 back 键,再打开app,会调用onCreate()

public class MainActivity extends Activity {

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i("MainActivity", "---------------------------onCreate ");
} @Override
protected void onNewIntent(Intent intent) { Log.i("MainActivity", "---------------------------onNewIntent intent = "+intent);
setIntent(intent);
super.onNewIntent(intent);
} }
 <activity
android:name="com.example.badupush.MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

onCreate是用来创建一个activity的,但activity处于任务栈的顶端时,再次打开该Activity不会调用onCreate。

如果你想用这个顶端的activity去处理新的Intent,可以利用onNewIntent()

onNewIntent 作用的更多相关文章

  1. Android应用开发中Intent的作用及使用方法

    Intent是一种运行时绑定(run-time binding)机制,它能在程序运行过程中连接两个不同的组件.通过Intent,你的程序可以向Android表达某种请求或者意愿,Android会根据意 ...

  2. if __name__== "__main__" 的意思(作用)python代码复用

    if __name__== "__main__" 的意思(作用)python代码复用 转自:大步's Blog  http://www.dabu.info/if-__-name__ ...

  3. (转载)linux下各个文件夹的作用

    linux下的文件结构,看看每个文件夹都是干吗用的/bin 二进制可执行命令 /dev 设备特殊文件 /etc 系统管理和配置文件 /etc/rc.d 启动的配置文件和脚本 /home 用户主目录的基 ...

  4. github中的watch、star、fork的作用

    [转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...

  5. web.xml中welcome-file-list的作用

    今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...

  6. web.xml中load-on-startup的作用

    如下一段配置,熟悉DWR的再熟悉不过了:<servlet>   <servlet-name>dwr-invoker</servlet-name>   <ser ...

  7. SQLSERVER中NULL位图的作用

    SQLSERVER中NULL位图的作用 首先感谢宋沄剑提供的文章和sqlskill网站:www.sqlskills.com,看下面文章之前请先看一下下面两篇文章 SQL Server误区30日谈-Da ...

  8. 电容与EMC-电容不同功能时对整板EMC的作用

    一般我们的pcb板的器件有很多种类,但是值得特别关注的,很多人都会说是BGA.接口.IC.晶振之类,因为这些都是layout功能模块以及设计难点.然而数量上占绝对优势的器件却是阻容器件,之前围殴阻抗时 ...

  9. FTP的搭建与虚拟目录作用<之简单讲解>

    操作系统:win7 VS2010编写WebService与在IIS的发布<之简单讲解>中我已经说了IIS安装与使用,不明白的可以跳过去看. 1.添加FTP站点 2. 3. 4. 5. zq ...

随机推荐

  1. 防止js拦截跳转请求的方法

    不要直接使用window.open这个方法. 考虑下使用下面这个: openWindow: function(url){ var link = document.createElement('a'); ...

  2. [shell]简单的shell提示和参数脚本

    该shell脚本有如下点: bash or dash case语句的写法 脚本help写法 参数是否为空的写法 算数运算的写法 #! /bin/bash case "$1" in ...

  3. mac环境搭建selenium

    前言 搭建python+selenium,mac自带python2.7,需要公司使用的python是3.x,可以自己百度安装python环境. 1. selenium安装 1. selenium的安装 ...

  4. git 停止在12% writing objects 怎么回事?

    git 停止在12% writing objects 怎么回事? 输入以下代码试一下: git config --global http.postBuffer 524288000  

  5. php中判断一个字符是否在字符串中

    strpos() - 查找字符串在另一字符串中第一次出现的位置(区分大小写) stripos() - 查找字符串在另一字符串中第一次出现的位置(不区分大小写) strrpos() - 查找字符串在另一 ...

  6. 用Powershell调用DLL文件

    http://blog.csdn.net/itanders/article/details/5702771

  7. HDU 2159 FATE(二维全然背包)

    中文题目就不用解释了   就是裸的二维全然背包 d[i][j]表示消耗i忍耐杀j个怪最多可获得的经验  然后就用全然背包来做了  二维背包背包只是是多了一重循环 <span style=&quo ...

  8. Codeforces 417 D. Cunning Gena

    按monitor排序,然后状压DP... . D. Cunning Gena time limit per test 1 second memory limit per test 256 megaby ...

  9. 剑指 offer set 27 赋值运算符函数

    要求为类 CMyString 定义赋值运算符函数. 类的定义如下 class CMyString { public: CMyString(char* pData = NULL; ) CMyString ...

  10. Spring学习笔记--使用Spring基于Java的配置

    我们需要使用@Component注解来定义一个配置类,在配置类中我们定义Bean: package com.moonlit.myspring; import org.springframework.c ...