我可以更改正在运行的活动的android:noHistory属性吗?

时间:2011-06-11 04:51:06

标签: android android-activity history

是否可以动态更改活动程序的android:noHistory属性值?

或许还有另一种方法可以做我想要的。我有一个QuickContactBadges活动...我希望它在弹出QuickContact后关闭活动,这就是我打开noHistory的原因,但活动也会启动配置活动。我不希望它从该活动回来时关闭(相反它应该刷新,如果我可以阻止它关闭,我可以这样做。)

2 个答案:

答案 0 :(得分:2)

修订答案

您可以使用默认布尔值true作为活动onPause()方法中的触发器,告诉您是否要调用finish()。如果用户到达调用Configuration Activity的Activity部分,请将boolean设置为false,这样Activity就不会完成也不会从堆栈中删除。

答案 1 :(得分:-2)

<activity android:allowTaskReparenting=["true" | "false"]
          android:alwaysRetainTaskState=["true" | "false"]
          android:clearTaskOnLaunch=["true" | "false"]
          android:configChanges=["mcc", "mnc", "locale",
                                 "touchscreen", "keyboard", "keyboardHidden",
                                 "navigation", "orientation", "screenLayout",
                                 "fontScale", "uiMode"]
          android:enabled=["true" | "false"]
          android:excludeFromRecents=["true" | "false"]
          android:exported=["true" | "false"]
          android:finishOnTaskLaunch=["true" | "false"]
          android:hardwareAccelerated=["true" | "false"]
          android:icon="drawable resource"
          android:label="string resource"
          android:launchMode=["multiple" | "singleTop" |
                              "singleTask" | "singleInstance"]
          android:multiprocess=["true" | "false"]
          android:name="string"
          android:noHistory=["true" | "false"]  
          android:permission="string"
          android:process="string"
          android:screenOrientation=["unspecified" | "user" | "behind" |
                                     "landscape" | "portrait" |
                                     "sensor" | "nosensor"]
          android:stateNotNeeded=["true" | "false"]
          android:taskAffinity="string"
          android:theme="resource or theme"
          android:windowSoftInputMode=["stateUnspecified",
                                       "stateUnchanged", "stateHidden",
                                       "stateAlwaysHidden", "stateVisible",
                                       "stateAlwaysVisible", "adjustUnspecified",
                                       "adjustResize", "adjustPan"] >   
    . . .
</activity>

试试此链接 - &gt; http://developer.android.com/guide/topics/manifest/activity-element.html