android - Android - What is best way of handling http call in OnCreate which doesn't get called on screen rotation?
问题描述
I am learning android. Get stuck with a basic scenario of loading the data in oncreate of an activity. So I am trying to load the data as soon as i open my activity but when i change the screen orientation it gets called again. I understand that android restore the state of activity during screen orientation. so oncreate method get called. But my problem is once the data get downloaded i dont want to make an Http call over and over. What should be best possible way to handle this? I want different layout for different screen orientation but data is same. I have to load the data in oncreate.
解决方案
推荐阅读
- javascript - 如何根据 createdAt 显示数组的最后 2 个元素
- xcode - 在邻居的 ipad 上部署 xamarin 表单应用程序失败
- swift - Xcode 11.4.1 Core Data 模型无法识别
- kotlin - 如何在 Kotlin 中安全地进行转换(无空转换)
- java - 如何在 Java Web 应用程序中适当地配置服务器、XML 和 JSP 文件?
- c++ - 无法显式实例化模板类
- webgl2 - 如何在 WebGL2 中创建内部格式为“RG8UI”的纹理?
- sql - 如果我更喜欢使用 raw 而不是其内置功能,那么使用 Knex 是否毫无意义?
- r-markdown - 如何使用 loveit 主题和 blogdown 制作浮动目录
- html - 如何在使用 shape-outside 创建的圆圈内垂直居中文本?