onNewIntent 什么时候调用
2011-05-24 21:30
218 查看
protected void onNewIntent (Intent intent)
Since: API Level 1This is called for activities that set launchMode to "singleTop" in their package, or if a client used the
FLAG_ACTIVITY_SINGLE_TOPflag 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
相关文章推荐
- onNewIntent 什么时候调用
- onNewIntent 什么时候调用
- onNewIntent调用时机及Activity的四种启动模式
- android onNewIntent的调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- Activity的四种launchMode以及onNewIntent()的调用时机
- OnNewIntent的调用时机
- onNewIntent调用时机
- 【Android】onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机
- onNewIntent调用时机