我用带有插件的安卓应用程序创建了PhoneGap 1.4。
我的客户报告说,当他使用Home按钮离开应用程序,然后使用应用图标重新启动应用程序时,应用程序从一开始就重新启动,而不是继续运行。然而,当他按下锁定或进入睡眠时,应用程序将按预期的方式恢复。
应用程序的初始化过程是这样声明的:
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();
}有没有办法解决这个问题,然后回到我暂停应用程序的地方?在这个过程中会有什么问题?
发布于 2013-07-11 20:47:25
我也有同样的问题。当我点击应用图标重新启动已经在后台运行的应用程序时,我的应用程序正在重新启动。
基本上如果
安卓:启动模式
设置为标准或不设置,然后为应用程序创建一个新的意图,并且不再恢复以前暂停的app状态。
所以我发现最好的方法就是申请
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>https://stackoverflow.com/questions/10912867
复制相似问题