首页 > 其他分享 >后台处理指南

后台处理指南

时间:2023-12-04 15:35:35浏览次数:33  
标签:指南 处理 app work running user background 后台 Android

后台处理指南  |  Android 开发者  |  Android Developers https://developer.android.google.cn/guide/background?hl=zh-cn

Processing data in the background is an important part of creating an Android application that is both responsive for your users as well as a good citizen on the Android platform. Doing work on the main thread can lead to poor performance and therefore a poor user experience.

This guide explains what qualifies as background work, defines background task categories, provides you with criteria to categorize your tasks, and recommends APIs that you should use to execute them.

Core principle

In general, you should take any blocking tasks off the UI thread. Common long-running tasks include things like decoding a bitmap, accessing storage, working on a machine learning (ML) model, or performing network requests.

Definition of background work

An app is running in the background when both the following conditions are satisfied:

  • None of the app's activities are currently visible to the user.
  • The app isn't running any foreground services that started while an activity from the app was visible to the user.

Otherwise, the app is running in the foreground.

Note: Consider a case in which a foreground service starts while an activity from the app is visible to the user. The user subsequently navigates away from the app and returns to the home screen. In such cases, the app is running in the foreground until the service's lifecycle ends.

Common types of background work

Background work falls into one of three primary categories:

  • Immediate: Needs to execute right away and complete soon.
  • Long Running: May take some time to complete.
  • Deferrable: Does not need to run right away.

Likewise, background work in each of these three categories can be either persistent or impersistent:

  • Persistent work: Remains scheduled through app restarts and device reboots.
  • Impersistent work: No longer scheduled after the process ends.

 Figure 1: Types of background work.

 

 

 

翻译

搜索

复制

标签:指南,处理,app,work,running,user,background,后台,Android
From: https://www.cnblogs.com/papering/p/17875050.html

相关文章

  • Java开发者的Python快速实战指南:探索向量数据库之图像相似搜索-文字版
    首先,我要向大家道个歉。原本我计划今天向大家展示如何将图片和视频等形式转换为向量并存储在向量数据库中,但是当我查看文档时才发现,腾讯的向量数据库尚未完全开发完成。因此,今天我将用文本形式来演示相似图片搜索。如果您对腾讯的产品动态不太了解,可以查看官方网址:https://cloud.t......
  • Markdown语法入门与进阶指南
    一、Markdown简介Markdown是一种轻量级标记语言,创始人为约翰·格鲁伯(johnGruber)。它允许人们使用易读易写的纯文本格式编写文档,然后转换成有效的XHTML(或者HTML)文档。这种语言吸收了很多在电子邮件中已有的纯文本标记的特性。Markdown在线编辑器--一个覆盖广泛主题工具的高......
  • python处理Excel文件
    一.读取Excel文件在Python中,你可以使用pandas库来读取Excel文件。首先,确保你已经安装了pandas和openpyxl库。如果没有安装,可以使用以下命令进行安装:pipinstallpandasopenpyxl安装完成后,你可以使用以下代码来读取Excel文件:importpandasaspd#读取Excel文件fil......
  • Java异常处理
    异常处理是Java编程中的一个核心概念,它提供了一种强大的方法来处理运行时错误,使我们的程序更加健壮。异常是程序运行过程中发生的不正常情况,它打断了正常的指令流。本文将介绍Java中的异常处理机制,包括异常的类型、如何捕获和处理异常,以及自定义异常。异常类型在Java中,所有的异常都......
  • 《最新出炉》系列初窥篇-Python+Playwright自动化测试-35-处理web页面定位toast-上篇
    1.简介在使用appium写app自动化的时候介绍toast的相关元素的定位,在WebUI测试过程中,也经常遇到一些toast(出现之后一闪而过,不留下一点点痕迹),那么这个toast我们这边如何使用playwright进行定位测试呢?今天宏哥就分两篇介绍一下。2.什么是toast?Android中的Toast是一种简易的消......
  • 英特尔 N100 处理器跑分出炉:达 i5-7400 水平
    英特尔今年推出了采用最新Intel7工艺的全小核处理器,其中N100为4核4线程。在最新的Geekbench6跑分平台上,N100的成绩与英特尔i5-7400桌面处理器基本一致。IntelN100Inteli5-7400如上图所示,英特尔N100处理器跑分虽然不算高,但不论单核还是多核,分数均达到了i5......
  • Python中用requests处理cookies的3种方法
    在接口测试中,大多数项目的接口是需要登录后进行操作的,经常用到requests库进行模拟登录及登录后的操作,下面是我不断踩坑后总结出来的关于登录凭证cookies的3种操作方法。一.用requests.utils.dict_from_cookiejar()把返回的cookies转换成字典1.处理cookies:importreques......
  • 处理XML-----xPath
    1从根节点筛选/2条件筛选选择category属性为'fiction'的<book>节点:/bookstore/book[@category='fiction']选择price属性大于30的<book>节点/bookstore/book[@price>30]选择不包含某个属性的节点//bookstore/book[not(@category)]3......
  • obs个人使用指南
    obs篇基本信息obs软件官网:https://obsproject.com/obs附属论坛:https://obsproject.com/forum/obs插件库:https://obsproject.com/forum/plugins/脚本使用指南(以autosplitter为例)首先我们在对应得脚本页面,获取下载链接类似脚本链接会直接打开github得源代码,我们直接......
  • SpringBoot 统一异常处理
    1.在SpringBoot中项目中常见的统一异常处理方式是:使用@RestControllerAdvice和@ExceptionHandler注解。项目中的所有类型异常都会被抛到统一异常处理类中统一处理。预期效果如下:2.新建一个异常类ParamValidException,继承RuntimeException.@DatapublicclassParamValidExcepti......