protected void
onNewIntent
(Intent
intent)
This is called for activities that set launchMode to "singleTop" in their package, or if a client used theFLAG_ACTIVITY_SINGLE_TOP
flag when calling startActivity(Intent)
.
In either case, when the activity is re-launched while at the top of
the activity stack instead of a new instance of the activity being
started, onNewIntent() will be called on the existing instance with the
Intent that was used to re-launch it.
An activity will always be paused before receiving a new intent, so you can count on onResume()
being called after this method.
Note that getIntent()
still returns the original Intent. You can use setIntent(Intent)
to update it to this new Intent.
在IntentActivity中重写下列方法:onCreate onStart onRestart onResume onPause onStop onDestroy onNewIntent
一、其他应用发Intent,执行下列方法:
I/@@@philn(12410): onCreate
I/@@@philn(12410): onStart
I/@@@philn(12410): onResume
发Intent的方法:
Uri uri = Uri.parse("philn://blog.163.com");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
二、接收Intent声明:
<activity android:name=".IntentActivity" android:launchMode="singleTask"
android:label="@string/testname">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="philn"/>
</intent-filter>
</activity>
三、如果IntentActivity处于任务栈的顶端,也就是说之前打开过的Activity,现在处于
I/@@@philn(12410): onPause
I/@@@philn(12410): onStop 状态的话
其他应用再发送Intent的话,执行顺序为:
I/@@@philn(12410): onNewIntent
I/@@@philn(12410): onRestart
I/@@@philn(12410): onStart
I/@@@philn(12410): onResume
分享到:
相关推荐
android onNewIntent方法调用的问题跟launchmode有关
这个demo主要讲解了 onNewIntent() 方法的使用,希望可以帮助需要的同学.
一、onNewIntent() 在IntentActivity中重写下列方法:onCreate onStart onRestart onResume onPause onStop onDestroy onNewIntent 1、其他应用发Intent,执行下列方法: onCreate onStart onResume 发Intent的...
activity的四种启动模式和onNewIntent的关系
android onnewintent机制
android 中activity的启动模式分为四种,(standard、singleTop、singTask、singleInstance),本文通过实例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友参考下吧
1.支持android设备读取nfc贴纸数据 2.支持向nfc卡中写入相关的数据 3.操作非常简单,只需要在在Activity中的onResume、onPause、onDestroy、onNewIntent方法中调用nfc工具类的相关方法就ok了,完整的步骤请查看demo
如果在任务的栈顶正好存在该Activity的实例,就重用该实例,并且会调用实例的OnNewIntent()方法,否者就会创建新的实例并放入栈顶(即使栈中已经存在该Activity实例,只要不在栈顶,都会创建实例)。 3.singleTask ...
实现onNewIntent(Intent intent) onNewIntent(Intent intent) 对QT的C ++端的JNI调用public static native void setUrl(String url) C ++实现openurlclient.cpp JNI调用的实现 JNIEXPORT void JNICALL Java_...
一些实验:在通过方法通道对MainActivity的每次调用中,在Mainactivity端调用onResume,因此没有创建新的活动(并且不调用onNewIntent),因此保留了非接触卡的连接状态,这非常好。 因此,您可以根据需要在...
如何使用使用uri字符串或intent实例调用UriDispatcher#dispatch 。 @Overrideprotected void onNewIntent( final Intent intent) { super . onNewIntent(intent); UriDispatcher . dispatch( this , intent);} 称为...
2 设置入口activity的启动模式android:launchMode="singleTask",重写onNewIntent方法, 在退出activity时,设置intent.setAction("exit_app");然后跳转到栈底activity, 这样就可以清除栈底之外的所有activity,...
插件NFC 一个跨平台NFC(近场通信)插件,可轻松在您的应用程序中读写NFC标签。 该插件使用NDEF ( NFC数据交换格式)来最大程度地在NFC设备,标签类型和操作系统之间实现兼容性。 状态 包 建立 ...
Activity的四种启动模式: 1. standard ... 如果在栈中已经有该Activity的实例,就重用该实例(会调用实例的onNewIntent())。重用时,会让该实例回到栈顶,因此在它上面的实例将会被移除栈。如果
Activity的onNewIntent函数可能不会被触发。 (此为BUG,未来会修复) 缺乏对Native层的Hook,对某些带native代码的apk支持不好,可能无法运行。比如一部分游戏无法当作插件运行。 特点: 支持Androd 2.3以上系统 ...
Activity的onNewIntent函数可能不会被触发。 (此为BUG,未来会修复)缺乏对Native层的Hook,对某些带native代码的apk支持不好,可能无法运行。比如一部分游戏无法当作插件运行。特点:支持Androd 2.3以上系统插件...
因为项目中有登录控制,所以需要在MainActivity中判断是否登录;如果登录状态,那么就直接跳转;如果未登录,则先保存要跳转的界面数据然后到登录...这里MainActivity的启动模式为singleTask,需要注意onNewIntent方法
QQ,微博,微信的登录和分享必须通过LoginSharePay类来实现,如果你只想实现登录功能,那么这两个方法就可以不用实现(onNewIntent(Intent intent),onActivityResult(int requestCode, int resultCode, Intent data))...
当有新内容到来时直接更新【在onNewIntent内】就好了;然而,我发现更新内容后布局不能再包裹内容了,做过问题着实困扰了我半天。晚上写了做过小demo,发现如果在更新内容之前,将布局的layoutparas设置为wrap_...