Android如何在没有意图或背景的情况下开始活动 [英] Android how to start activity without intent or backround
问题描述
假设我有两个活动A和B,活动A包含一个按钮,当我无意按下Button时,我想启动活动B.
Suppose I have two activities A and B activity A which contains a button I want to start Activity B when I press Button without intent.
推荐答案
根据官方文档:
意图是要执行的操作的抽象描述.它可以与 startActivity
一起使用来启动 Activity
, broadcastIntent
并将其发送到任何感兴趣的 BroadcastReceiver
组件,以及 startService(Intent)
或 bindService(Intent,ServiceConnection,int)
与后台Service通信.
An intent is an abstract description of an operation to be performed. It can be used with startActivity
to launch an Activity
, broadcastIntent
to send it to any interested BroadcastReceiver
components, and startService(Intent)
or bindService(Intent, ServiceConnection, int)
to communicate with a background Service.
Intent
提供了一种在不同应用程序中的代码之间执行后期运行时绑定的功能.它最重要的用途是在启动活动时,可以将其视为活动之间的粘合剂.它基本上是一种被动数据结构,其中包含要执行的动作的抽象描述.
An Intent
provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.
因此,您必须使用它来打开活动,而没有任何例外或变通方法,如果这样做,您将忽略整个系统体系结构.
So you have to use it to open activities with no exceptions or workarounds, if you do that, you are ignoring the entire system architecture.
这篇关于Android如何在没有意图或背景的情况下开始活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!