gpt4 book ai didi

java - 如何在恢复后运行上次查看的 Activity ?

转载 作者:太空宇宙 更新时间:2023-11-04 13:58:09 25 4
gpt4 key购买 nike

我有一个 Android 应用程序。如果我浏览 Activity (例如 MainTabActivity->SearchMapActivity->ListBranchesActivity),然后隐藏(而不是关闭)我的应用程序,Android 将在重新打开后运行主(MainTabActivity) Activity 。如果我按“后退”按钮,Android 将显示最后一个 Activity (ListBranchesActivity)。如何让我的应用程序在恢复后显示上次 Activity ?我真的不知道如何实现这一目标。有人说将 singleTask 语句添加到 list 中。我的 list :

 <application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo"
android:largeHeap="true" >


<activity
android:name=".SearchMapActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">

<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".UpdateActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".CompanyInfoActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".FullMapActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".ListBranchesActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".ListCompaniesByBranchActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".SearchResultActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">


<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>



<activity
android:name=".MainTabActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>

<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

而且这种事情并不是每次都会发生。有时它显示最后一个 Activity ,有时 - 主要 Activity 。

最佳答案

 > Also that thing doesn't happen everytime. Sometimes 
> it shows last activity, sometimes - main activity.

有时,如果您的应用程序需要内存,Android 会关闭它。因此,即使您隐藏(未关闭)...[该]应用程序,它也可能已被关闭

关于java - 如何在恢复后运行上次查看的 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29600290/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com