遍历

栏目: Android · 发布时间: 5年前

  1. A使用startActivityForResult开启BA,BA中调用setResult+finish返回A.两者生命周期
A:
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.e("Jet","A:onActivityResult");
    if(resultCode==101){
        Log.e("Jet","A:onActivityResult:101");
    }
}

public void startActivityForResultLC(View view) {
    Intent intent = new Intent(this,BA.class);
    startActivityForResult(intent,100);
}
BA:
public void setResultTest(View view) {
    setResult(101);
    finish();
}

Log:
2018-11-28 11:18:58.837 E/Jet: A:onCreate
2018-11-28 11:18:58.861 E/Jet: A:onStart
2018-11-28 11:18:58.867 E/Jet: A:onResume
2018-11-28 11:19:02.615 E/Jet: A:onPause
2018-11-28 11:19:02.750 E/Jet: BA:onCreate
2018-11-28 11:19:02.760 E/Jet: BA:onStart
2018-11-28 11:19:02.763 E/Jet: BA:onResume
2018-11-28 11:19:03.375 E/Jet: A:onStop
2018-11-28 11:19:09.134 E/Jet: BA:onPause
2018-11-28 11:19:09.162 E/Jet: A:onActivityResult
2018-11-28 11:19:09.162 E/Jet: A:onActivityResult:101
2018-11-28 11:19:09.167 E/Jet: A:onRestart
2018-11-28 11:19:09.168 E/Jet: A:onStart
2018-11-28 11:19:09.172 E/Jet: A:onResume
2018-11-28 11:19:09.733 E/Jet: BA:onStop
2018-11-28 11:19:09.737 E/Jet: BA:onDestroy
复制代码

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The NSHipster Fake Book (Objective-C)

The NSHipster Fake Book (Objective-C)

Mattt Thompson / NSHipster Portland, Oregon / 2014 / USD 19.00

Fake Books are an indispensable tool for jazz musicians. They contain the melody, rhythm, and chord changes for hundreds of standards, allowing a player to jump into any session cold, and "fake it" th......一起来看看 《The NSHipster Fake Book (Objective-C)》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

随机密码生成器
随机密码生成器

多种字符组合密码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器