您的位置:首页 > 移动开发 > Android开发

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

2016-08-10 14:48 435 查看
一、onNewIntent()

在IntentActivity中重写下列方法:onCreate
onStart onRestart  onResume  onPause onStop onDestroy  onNewIntent

1、其他应用发Intent,执行下列方法:
onCreate
onStart
onResume

发Intent的方法:

Uri uri = Uri.parse("philn://blog.163.com");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);

<activity android:label="@string/app_name" android:launchmode="singleTask"android:name="Activity1"></activity>


public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

processExtraData();

}

protected void onNewIntent(Intent intent) {

super.onNewIntent(intent);

setIntent(intent);//must store the new intent unless getIntent() will return the old one

processExtraData()

}

private void processExtraData(){

Intent intent = getIntent();

//use the data received here

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: