gpt4 book ai didi

android - 单击主页按钮后,Phonegap Android 应用程序重新启动而不是恢复

转载 作者:太空狗 更新时间:2023-10-29 12:52:26 25 4
gpt4 key购买 nike

我已经使用带插件的 Android 应用程序创建了 PhoneGap 1.4/。

我的客户报告说,当他使用主页按钮离开应用程序,然后使用应用程序图标重新启动它时,应用程序会从头重新启动而不是恢复。但是,当他按下锁定或进入休眠状态时,应用程序会以预期的方式恢复。

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

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("EMOFIDActivity", "onCreatee " + this.getIntent());
super.loadUrl("file:///android_asset/www/index.html");
}
@Override
public void onPause() {
Log.d("EMOFIDActivity", "onPause " + this.getIntent());
super.onPause();
}// On click of home button this method is getting called

@Override
public void onResume() {
Log.d("EMOFIDActivity", "onResume " + this.getIntent());
super.onResume();
} // On click of app icon application is getting relaunched without coming to this function.

我已经包含了三个 android 插件并像这样覆盖了 onPause() 和 onResume() 方法。这里也根本没有调用 OnResume() 方法。

    @Override
public void onPause(boolean multitasking) {
Log.d(TAG, "onPause " + ctx.getIntent());
super.onPause(multitasking);
stopNfc();
}

@Override
public void onResume(boolean multitasking) {
Log.d(TAG, "onResume " + ctx.getIntent());
super.onResume(multitasking);
startNfc();
}

有没有办法解决这个问题并返回到我暂停应用程序的状态?这个过程中可能存在什么问题?

最佳答案

我遇到了同样的问题。当我单击应用程序图标以重新启动已在后台运行的应用程序时,我的应用程序正在重新启动。

基本上如果

android:launchMode

设置为标准或未设置,然后为应用程序创建一个新的 Intent 并且应用程序的旧暂停状态不会恢复。

所以我发现最好的方法是申请

android:launchMode="singleTask"

在 AndroidManifest.xml -> 里面。

请考虑这个例子:

  <activity android:name="Example" android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

关于android - 单击主页按钮后,Phonegap Android 应用程序重新启动而不是恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10912867/

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