`

onNewIntent()与singleTask启动模式

 
阅读更多

当有一个活动A设置启动模式为singleTask模式时。

 又有多个其他活动需 经过Intent 跳转到活动A,并附带信息。 那么肯定会设置action!

当活动A 判定是哪一个活动过来的时候。

 

  当活动A没被系统杀了。活动A的oncreate 将不执行,先执行onNewIntent,再onResume!

 所以在onNewIntent里面 可

 

  1. @Override   
  2. public   void  onNewIntent(Intent arg0) {  
  3.     // TODO Auto-generated method stub   
  4.     super .onNewIntent(arg0);  
  5.     System.out.println("OnNewIntent进来了" );  
  6.     setIntent(arg0);  
  7.     intent = this .getIntent();  
  8. }  
	@Override
	public void onNewIntent(Intent arg0) {
		// TODO Auto-generated method stub
		super.onNewIntent(arg0);
		System.out.println("OnNewIntent进来了");
		setIntent(arg0);
		intent = this.getIntent();
	}

 

 关键是 setintent(arg0);

 只有设置了这个 才会更新 intent。(action)
否则一直是第一个跳转到活动A的那个intent的action

分享到:
评论

相关推荐

    activity的四种启动模式和onNewIntent的关系

    activity的四种启动模式和onNewIntent的关系

    Android onNewIntent()触发机制及注意事项

    一、onNewIntent() 在IntentActivity中重写下列方法:onCreate onStart onRestart onResume onPause onStop onDestroy onNewIntent 1、其他应用发Intent,执行下列方法: onCreate onStart onResume 发Intent的...

    android中的Activity启动方式

    Android总Activity的启动模式分为四种: Activity启动模式设置: Activity的四种启动模式: 1.standard 模式启动模式,每次激活Activity时都会创建Activity,并放入任务栈中。 2.singleTop 如果在任务的栈顶...

    onNewIntent

    android onNewIntent方法调用的问题跟launchmode有关

    Android中Activity的四种启动模式和onNewIntent()

    android 中activity的启动模式分为四种,(standard、singleTop、singTask、singleInstance),本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友参考下吧

    onNewIntent方法的使用

    这个demo主要讲解了 onNewIntent() 方法的使用,希望可以帮助需要的同学.

    如何正确理解和使用Activity的4种启动模式

    关于Activity启动模式的文章已经很多,但有的文章写得过于简单,有的则过于注重细节,本文想取一个折中,只关注最重要和最常用的概念,原理和使用方法,便于读者正确应用。 Activity的启动模式有4种,分别是standard...

    详解Activity之singletast启动模式及如何使用intent传值

    Activity的四种启动模式:  1. standard  模式启动模式,每次激活Activity时都会创建Activity,并放入任务栈中。  2. singleTop  如果在任务的栈顶正好存在该Activity的实例, 就重用该实例,否者就会创建新的...

    android onnewintent

    android onnewintent机制

    android 退出app 退出应用程序

    2 设置入口activity的启动模式android:launchMode="singleTask",重写onNewIntent方法, 在退出activity时,设置intent.setAction("exit_app");然后跳转到栈底activity, 这样就可以清除栈底之外的所有activity,...

    html链接打开app并跳转至某个指定界面

    因为项目中有登录控制,所以需要在MainActivity中判断是否登录;如果登录状态,那么就直接跳转;如果未登录,则先保存要跳转的界面数据然后到登录...这里MainActivity的启动模式为singleTask,需要注意onNewIntent方法

    open-url-in-qt-android:迷你概念证明示例,如何通过单击链接在Android上启动QT应用程序

    示例实现示例,以演示如何通过单击具有特定架构的链接( pocintent:// )来在Android上启动QT应用程序。 重要的部分是: poc.intent.OpenUrlClient扩展了QtActivity 实现onNewIntent(Intent intent) onNewIntent...

    Plugin.NFC:跨平台NFC(近场通信)插件,可轻松在您的应用程序中读写NFC标签

    插件NFC 一个跨平台NFC(近场通信)插件,可轻松在您的应用程序中读写NFC标签。 该插件使用NDEF ( NFC数据交换格式)来最大程度地在NFC设备,标签类型和操作系统之间实现兼容性。 状态 包 建立 ...

    XFragment:单Activity和多Fragment容器

    并且也支持特地的fragemnt* 支持fragment跳转的launch mode,目前支持standard,singleTop和singleTask,并且模拟了类似activity的onNewIntent()* 支持类似activity的onActivityResult()的回调,fragment采用了监听...

    360黑科技DroidPlugin.zip

    启动插件:启动插件的Activity、Service等都和你启动一个以及安装在系统中的app一样,使用系统提供的相关API即可。组件间通讯也是如此。实现原理:请参见源码支持:任何问题可以在项目中提交bug报告,也可以发送邮件...

    Android 退出多Activity的application的方式方法

    4.采用SingleTask的特点,结束应用 5.第四种方式的更优雅实现 6.双击返回键退出 方式一:利用ActivityContainer管理所有的Activity引用 该方式是建立一个通用的Activity的父类 BaseActivity以及一个...

    android-uri-dispatcher

    @Overrideprotected void onNewIntent( final Intent intent) { super . onNewIntent(intent); UriDispatcher . dispatch( this , intent);} 称为适当的方法。 @MatchUri ( " scheme-test://host " )public void ...

    android nfc常用标签读取总结

    与Wi-Fi、蓝牙、红外线等数据传输技术的一个主要差异就是有效距离一般不能超过4厘米。但是NFC传输速度要比红外快。目前NFC已经出现了一些应用,例如电子标签识别、刷手机、点对点付款、身份识别、信息记录等,本篇...

    android nfc 读写demo

    1.支持android设备读取nfc贴纸数据 2.支持向nfc卡中写入相关的数据 3.操作非常简单,只需要在在Activity中的onResume、onPause、onDestroy、onNewIntent方法中调用nfc工具类的相关方法就ok了,完整的步骤请查看demo

Global site tag (gtag.js) - Google Analytics