我正在开发一个 Android/Phonegap 应用程序。下面是我的代码:
public class SharePointProjectActivity extends DroidGap {
/* SharedPreferences are used so that any initial setup can be done,
* i.e operations that are done once in life-time of an application
* such as coping of database file to required location, initial wait
* request page,etc.
*/
private SharedPreferences myPreferences;
private Boolean registration;
private static final String PREFS_NAME = "Register";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
myPreferences = PreferenceManager.getDefaultSharedPreferences(this);
registration = myPreferences.getBoolean(PREFS_NAME, false);
if (!registration) {
//this code would load index1.html which would just display "Initialization is going on please wait"
super.loadUrl("file:///android_asset/www/index1.html");
try {
//some code to copy the database files
}
catch (IOException e) {
//some exception during the operation
}
//once the database file are copied i want to load the login page.Remember this would happen during installation only, successive runs (launch) would directly load the login page i.e index2.html
super.loadUrl("file:///android_asset/www/index2.html");
SharedPreferences.Editor editor = myPreferences.edit();
editor.putBoolean(PREFS_NAME, true);
editor.commit();
} else {
super.loadUrl("file:///android_asset/www/index.html");
}
}
问题:在安装过程中,两个页面都在另一个之上加载,即 index2.html 在 index1.html 之上。
预期:在复制过程中,应该显示 index1.html,一旦完成,index1.html 应该会消失并且 index2.html 应该加载。
编辑:我将在安装过程中使用两个 html 文件,第一个文件将只显示一个图像,要求用户在安装过程中等待,如果一切正常,则应该加载登录页面(第二个文件)。到目前为止,这是可行的,但是当我单击后退按钮时,控件会转到第一页。提前致谢,
七无