[英]Is there any way to know if an activity has a parent activity or not?
Upon clicking a button in an activity, I want to display Page1 if this activity has a parent activity and display Page2 if it does not (ie it is the Main Activity that is started when I started the application). 单击活动中的按钮后,如果此活动具有父活动,则显示Page1,如果不活动,则显示Page2(即,当我启动应用程序时,它是启动的主活动)。
Yes, getParentActivityIntent()
是的,
getParentActivityIntent()
Obtain an Intent that will launch an explicit target activity specified by this activity's logical parent. 获取将启动此活动的逻辑父级指定的显式目标活动的Intent。 The logical parent is named in the application's manifest by the parentActivityName attribute.
逻辑父级由parentActivityName属性在应用程序的清单中命名。 Activity subclasses may override this method to modify the Intent returned by super.getParentActivityIntent() or to implement a different mechanism for retrieving the parent intent entirely.
Activity子类可以重写此方法以修改super.getParentActivityIntent()返回的Intent,或者实现完全检索父intent的不同机制。
Returns a new Intent targeting the defined parent of this activity or null if there is no valid parent. 返回以此活动的已定义父项为目标的新Intent,如果没有有效父项,则返回null。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.