android onresume方法,Android onActivityResult()和onResume()的执行顺序

android onresume方法,Android onActivityResult()和onResume()的执行顺序问题回顾:在Android8.0手机上不能直接安装Apk,需要权限申请,回调后执行onActivityResult()方法,并弹出对应的dialog,这时需要判断当前Activity是否处于resume状态,通过变量来控制,但结果是这个dialog并不会弹出。问题本质Activity跳转到系统应用后回调onActivityResult()先执行还是onResume()先执行?查看源码/***C…

大家好,又见面了,我是你们的朋友全栈君。

问题回顾:

在Android8.0手机上不能直接安装Apk,需要权限申请,回调后执行onActivityResult()方法,并弹出对应的dialog,这时需要判断当前Activity是否处于resume状态,通过变量来控制,但结果是这个dialog并不会弹出。

问题本质

Activity跳转到系统应用后回调onActivityResult() 先执行还是onResume()先执行?

查看源码

/**

* Called when an activity you launched exits, giving you the requestCode

* you started it with, the resultCode it returned, and any additional

* data from it. The resultCode will be

* {@link #RESULT_CANCELED} if the activity explicitly returned that,

* didn’t return any result, or crashed during its operation.

*

*

You will receive this call immediately before onResume() when your

* activity is re-starting.

*

*

This method is never invoked if your activity sets

* {@link android.R.styleable#AndroidManifestActivity_noHistory noHistory} to

* true.

*

* @param requestCode The integer request code originally supplied to

* startActivityForResult(), allowing you to identify who this

* result came from.

* @param resultCode The integer result code returned by the child activity

* through its setResult().

* @param data An Intent, which can return result data to the caller

* (various data can be attached to Intent “extras”).

*

* @see #startActivityForResult

* @see #createPendingResult

* @see #setResult(int)

*/

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

}

onActivityResult()注释中有这么一句话:

You will receive this call immediately before onResume() when your activity is re-starting.

(意思是说当你的Activity重新启动时 onActivityResult() 会在onResume()之前执行)

很显然,如果你的Activity 调用了 startActivityForResult() 方法启动,回调之后会先执行 onActivityResult() ,然后执行onResume()

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/139798.html原文链接:https://javaforall.net

(0)
上一篇 2022年5月29日 上午8:46
下一篇 2022年5月29日 上午8:46


相关推荐

  • Response.Flush()的用处

    Response.Flush()的用处Response.Flush()的作用是将缓冲信息输出到页面。比如我们在点击一个按钮后,执行多个任务,每个任务执行成功后都有一个Response.Write(‘成功信息’)。如果我们在Respons

    2022年7月2日
    26
  • eclipse搭建安卓开发环境

    eclipse搭建安卓开发环境总结起来,Android开发环境搭建可以分为以下四步:第一步、安装JDK;第二步、安装Eclipse;第三步、下载并安装AndroidSDK;第四步、为Eclipse安装ADT插件 下面详细介绍。第一步、安装JDKAndroid开发工具要求必须安装JDK(JavaDevelopmentKit),不能只安装JRE(JavaRuntimeEdition),在安装A…

    2022年7月23日
    13
  • awvs13使用教程_脚本网

    awvs13使用教程_脚本网你可以在以下渠道联系到我,转载请注明文章来源地址~知乎:Sp4rkWGITHUB:Sp4rkWB站:一只技术君博客:https://sp4rkw.blog.csdn.net/联系邮箱:getf_own@163.com文章目录前言核心接口仪表盘接口新增任务接口设置扫描速度启动扫描任务丝滑脚本前言最近在改reaper的awvs互动功能,因为自己的服务器垃圾,一次最多扫四个站,否则就卡死了。所以需要对现有的批量脚本进行修改处理。逻辑比较简单:拿到web资产,django异步启扫描任务从l

    2026年2月15日
    5
  • android之layout_weight体验(实现按比例显示)

    在android开发中LinearLayout很常用,LinearLayout的内控件的android:layout_weight在某些场景显得非常重要,比如我们需要按比例显示。android并没用提供table这样的控件,虽然有TableLayout,但是它并非是我们想象中的像html里面的table那么好用,我们常用ListView实现table的效果,但是列对齐确比较麻烦,现在用Linear

    2022年3月9日
    63
  • 【技术分享】pip切换镜像源及pip常用命令

    【技术分享】pip切换镜像源及pip常用命令pip切换镜像源国内比较出色的镜像源清华:https://pypi.tuna.tsinghua.edu.cn/simple阿里云:http://mirrors.aliyun.com/pypi/simple中国科技大学https://pypi.mirrors.ustc.edu.cn/simple方法一:切换镜像源#全局设置镜像源地址pipconfigsetglobal.index-urlhttps://pypi.tuna.tsinghua.edu.cn/simple方法二:从指定

    2022年5月11日
    44
  • 免费空间上的mysql数据库怎么连接?

    免费空间上的mysql数据库怎么连接?

    2021年9月20日
    46

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号