本文介绍了PhoneGap的Andr​​oid应用程序重新启动,而不是重新开始,虽然它不是由操作系统打死的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个PhoneGap的1.5 / Android应用程序。

I have created an Phonegap 1.5/Android application.

我的客户报告说,当他离开使用Home键的应用程序,然后使用应用程序图标重新推出它,应用程序从一开始,而不是恢复重新登场。然而,当他持有的home键,应用程序会出现在最近的应用程序,而当他访问此菜单的应用程序,该应用程序以预期的方式继续进行。

My client reports that, when he leaves the app using the Home button, and then relaunches it using the app icon, the app relaunches from the start instead of resuming. However, when he holds the home button, the app appears in the recent apps, and when he accesses the app through this menu, the app resumes in the expected way.

我想这可能与该应用程序由操作系统自动关闭,由于内存不足,但如果是这样的话,在最近的应用程序点击时,应用程序应该不会恢复。

I thought this could be linked to the app being automatically closed by the OS due to a lack of memory, but if that was the case the app shouldn't resume when clicked in the recent apps.

我无法重现bug在我的索尼爱立信XPERIA与Android 2.3.4,客户端已经经历了一个摩托罗拉Defy和另一部电话的这种行为(我会添加其他手机的参考和操作系统版本为当我让他们)。

I could not reproduce the bug on my Sony Ericsson XPERIA with Android 2.3.4, the client has experienced this behaviour on a Motorola Defy and on another phone (i'll add the reference of the other phone and the OS versions as soon as I get them).

应用程序的初始化过程中声明是这样的:

The initialization process of the app is declared this way :

window.addEventListener('load', function(){
      document.addEventListener('deviceready', _onDeviceReady, false);
}, false);

难道这是固定通过安装程序到其他事件(尽管我对此表示怀疑,应用程序似乎真的从一开始就重新启动)?

Could this be fixed by attaching the processes to other events (although I doubt it, the app really seems to be relaunched from the start) ?

有一个声明,使Android清单,以prevent这种行为?

Is there a declaration to make in the Android Manifest to prevent this behavior ?

下面是我的Andr​​oidManifest.xml活动签名

Here is the activity signature in my AndroidManifest.xml

    <application android:debuggable="true" android:icon="@drawable/appicon"
    android:label="@string/app_name" >
    <activity android:configChanges="orientation|keyboardHidden" android:name=".MyAppActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
 <activity android:name="com.phonegap.DroidGap" android:label="@string/app_name" 
           android:configChanges="orientation|keyboardHidden">
     <intent-filter>
     </intent-filter>
    </activity>
</application>

是在一些Android手机中的已知错误/版本?

Is that a known bug in some Android phones/versions ?

修改:按住home键不会显示当前正在运行的应用程序,但最近的应用程序。为什么会在菜单中的行为可以从主图标不同?

Edit : holding the home button does not display the currently running apps but the recent apps. Why would the behavior in that menu be different from the main icon ?

推荐答案

您想添加以下到您的Andr​​oidManifest.xml活动标签:

You want to add the following to the activity tag in your AndroidManifest.xml:

android:launchMode="singleTask"

因此​​,它应该是这样的:

So it should look like this:

<activity android:name="MyApp" android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar"
    android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
    android:launchMode="singleTask">

查看此页面上launchMode的更多信息:http://www.intridea.com/blog/2011/6/16/android-understanding-activity-launchmode

这篇关于PhoneGap的Andr​​oid应用程序重新启动,而不是重新开始,虽然它不是由操作系统打死的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 15:44