Android中查看启动或方法耗时的技巧

如何查看启动耗时

  1. 在AndroidStudio的Logcat窗口输入Displayed 关键字过滤,如下所示:

Android中的AOP面向切面编程

AOP 的应用场景

日志记录、性能统计、埋点统计、安全控制和异常处理。

子线程不可以更新UI吗

子线程不可以更新UI吗?(2019-11-05)

这里文章基于Android 系统8.0及以上版本分析子线程更新UI并没有报错的原因,其它版本并没有出现这种情况可以参考这篇文章子线程能更新UI吗。经常看到文章说不要在子线程更新UI,不要在UI线程进行耗时操作。偶然间的尝试发现了一些奇怪的问题,先分析第一个问题子线程中可以更新UI吗?下面是我的代码:

Android中的IPC之Binder机制

Android中的IPC机制即跨进程通信技术(Inter-Process-Comunicate),主要技术是 Android 的序列化机制和Binder。 Android 跨进程通信常见的几种方式;Bundle、文件共享、AIDL、Messenger、ContentProVider和Socket等。其中AIDL、Messenger、ContentProvider底层属于基于 Android Binder 机制实现的。

Android的Handler消息机制分析

Handler的介绍中出现最多的关键字,Looper,ThreadLocal,MessageQueue。

在工作线程的 handler#sendMessage 方法实际上是向主线程即UI线程的消息队列插入消息,通过ActivityThread初始化Looper对象,并通过Looper.looper方法循环查询消息队列的新消息。

Activity启动流程分析

本文基于Android 28 版本

Activity 的启动过程是从 startActivity 方法开始的,在Activity类中该方法最终调用 startActivityForResult 方法,如下所示:

Gradle 配置常见问题

常见gradle配置记录,如输出应用包名,相关debug和release版本信息分开配置等,对于gradle中常见问题如版本重复依赖版本冲突等问题的处理记录。

Rxjava操作符:第4篇 Combining Observables

本文基于Rxjava 2.x版本,介绍用于操作多个 Observable 对象的操作符。

Operators that work with multiple source Observables to create a single Observable

  • And/Then/When — combine sets of items emitted by two or more Observables by means of Patternand Plan intermediaries
  • CombineLatest — when an item is emitted by either of two Observables, combine the latest item emitted by each Observable via a specified function and emit items based on the results of this function
  • Join — combine items emitted by two Observables whenever an item from one Observable is emitted during a time window defined according to an item emitted by the other Observable
  • Merge — combine multiple Observables into one by merging their emissions
  • StartWith — emit a specified sequence of items before beginning to emit the items from the source Observable
  • Switch — convert an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables
  • Zip — combine the emissions of multiple Observables together via a specified function and emit single items for each combination based on the results of this function

Rxjava操作符:第3篇 Flitering Observable

本文基于Rxjava 2.x版本,介绍用于 Observable 过滤发射项目的操作符。

Operators that selectively emit items from a source Observable.

  • Debounce — only emit an item from an Observable if a particular timespan has passed without it emitting another item

    如果特定的时间跨度已经过去而没有发出另一个项目,则只从Observable中发出一个项目

  • Distinct — suppress duplicate items emitted by an Observable

    过滤重复发射源

  • ElementAt — emit only item n emitted by an Observable

    仅发出方法中指定的发射源

  • Filter — emit only those items from an Observable that pass a predicate test

    仅发出符合过滤条件的发射源

  • First — emit only the first item, or the first item that meets a condition, from an Observable

    仅保留发射序列的第一个发射源

  • IgnoreElements — do not emit any items from an Observable but mirror its termination notification

    忽略发射序列的所有元素,只会响应 onComplete 方法

  • Last — emit only the last item emitted by an Observable

    仅保留发射序列的最后一个发射源

  • Sample — emit the most recent item emitted by an Observable within periodic time intervals

    取每个时间周期内的最后一个发射源。

  • Skip — suppress the first n items emitted by an Observable

    跳过起始位置的 n 个发射源

  • SkipLast — suppress the last n items emitted by an Observable

    跳过终点位置的 n 个发射源

  • Take — emit only the first n items emitted by an Observable

    保留起始位置的 n 个发射源

  • TakeLast — emit only the last n items emitted by an Observable

    保留终点位置的 n 个发射源

Rxjava操作符:第2篇 Transforming Observable

本文基于Rxjava 2.x版本,介绍用于变换 Observable 对象的操作符。

Operators that transform items that are emitted by an Observable.

  • Buffer — periodically gather items from an Observable into bundles and emit these bundles rather than emitting the items one at a time

    定期将Observable中的项目收集到包中并发出这些包,而不是一次发送一个项目

  • FlatMap — transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable

    将Observable发出的项目转换为Observables,然后将这些项目的排放量变为单个Observable

  • GroupBy — divide an Observable into a set of Observables that each emit a different group of items from the original Observable, organized by key

    将一个Observable划分为一组Observable,每个Observable从原始Observable中发出一组不同的项目,按键组织

  • Map — transform the items emitted by an Observable by applying a function to each item

    通过将函数应用于每个项目来转换Observable发出的项目

  • Scan — apply a function to each item emitted by an Observable, sequentially, and emit each successive value

    将函数应用于Observable发出的每个项目,按顺序发出每个连续的值

  • Window — periodically subdivide items from an Observable into Observable windows and emit these windows rather than emitting the items one at a time

    定期将Observable中的项目细分为Observable窗口并发出这些窗口,而不是一次发出一个项目

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×