android - startActivity应该在主线程上执行吗?

标签 android multithreading android-layout

需要从一种 Activity 过渡到另一种 Activity 。需要在主线程上执行的startActivity(intent);可以是工作线程吗?我会选择主线程的概念,因为存在与GUI相关的操作。你怎么认为?

最佳答案

是的,应该这样做,但正如其他人所述,则不需要这样做。
基本上,就Context而言,“where”应该将新的Activity放在其堆栈中或其他堆栈的下方/上方。
From documentation:

Launch a new activity. You will not receive any information about when the activity exits.

Note that if this method is being called from outside of an Activity Context, then the Intent must include the FLAG_ACTIVITY_NEW_TASK launch flag. This is because, without being started from an existing Activity, there is no existing task in which to place the new activity and thus it needs to be placed in its own separate task.

关于android - startActivity应该在主线程上执行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39711087/

相关文章:

android - 通知服务

android - 如何在 renderscript 中使用半精度?

python - 从多个rest api流端点读取 - python

c++ - 客户端断开连接后处理服务器应用程序中的线程

android - 设置 ColorDrawable 的 alpha 不起作用

java - 性能损失最低的 volatile 替代品

android - 如何仅将图像添加到 listFragment 第一项?

android - 在绘制之前测量 RelativeView 的所有 subview

android - 工具栏菜单图标不显示

Android动态抽屉导航菜单项