在工作中,总是遇到一些问题,而今天给大家分享下我遇到的一个问题:
intent传值收不到:
launchMode为singleTask的时候,通过Intent启到一个Activity,如果系统已经存在一个实例,系统就会将请求发送到这个实例上,但这个时候,系统就不会再调用通常情况下我们处理请求数据的onCreate方法,而是调用onNewIntent方法
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);//必须要写
Intent intent = getIntent();
String name = intent.getStringExtra("name");而我们在其他生命周期来获取intent值时null,所以要在onNewIntent方法获取传递回来的intent值在做其他操作;
}