2015-04-22 82 views
0

APP處於暫停狀態。之後當我從最近的歷史記錄中選擇應用(暫停狀態恢復狀態)後,我正在更改手機的語言(本地化)。下面的生命週期方法調用在以下順序 的onDestroy 的onCreate 在onStart 的onResume 的onPause 的onStop 的onDestroy 但APP是不開放(圖未顯示)。 在這裏,我已經給出了活動和Android清單文件的源代碼。 任何幫助表示讚賞?cordova APP的本地化不起作用

public class CordovaExample extends DroidGap { 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      super.loadUrl("file:///android_asset/www/index.html"); 
      Log.i("onCreate Called","onCreate Called"); 
    } 
    @Override 
    protected void onStart() { 
     // TODO Auto-generated method stub 
     super.onStart(); 
     Log.i("OnStart Called","OnStart Called"); 
    } 
    @Override 
    protected void onResume() { 
     // TODO Auto-generated method stub 
     super.onResume(); 
     Log.i("onResume Called","onResume Called"); 
    } 

    @Override 
    protected void onPause() { 
     // TODO Auto-generated method stub 
     super.onPause(); 
     Log.i("onPause Called","onPause Called "+Locale.getDefault().getLanguage()); 
    } 
    @Override 
    protected void onStop() { 
     // TODO Auto-generated method stub 
     super.onStop(); 
     Log.i("onStop Called","onStop Called"); 

    } 
    @Override 
    public void onDestroy() { 
     // TODO Auto-generated method stub 
     super.onDestroy(); 
     Log.i("onDestroy Called","onDestroy Called"); 

    } 
} 

manifest資源配置文件:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="org.apache.cordova.rest" 
    android:hardwareAccelerated="true" 
    android:versionCode="1" 
    android:versionName="1.0" 
    android:windowSoftInputMode="adjustPan" > 

    <supports-screens 
     android:anyDensity="true" 
     android:largeScreens="true" 
     android:normalScreens="true" 
     android:resizeable="true" 
     android:smallScreens="true" 
     android:xlargeScreens="true" /> 

    <uses-permission android:name="android.permission.CAMERA" /> 
    <uses-permission android:name="android.permission.VIBRATE" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.RECEIVE_SMS" /> 
    <uses-permission android:name="android.permission.RECORD_AUDIO" /> 
    <uses-permission android:name="android.permission.RECORD_VIDEO" /> 
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 
    <uses-permission android:name="android.permission.READ_CONTACTS" /> 
    <uses-permission android:name="android.permission.WRITE_CONTACTS" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
    <uses-permission android:name="android.permission.BROADCAST_STICKY" /> 

    <application 
     android:hardwareAccelerated="true" 
     android:icon="@drawable/icon" 
     android:label="@string/app_name" > 
     <activity 
      android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" 
      android:name="org.apache.cordova.rest.CordovaRestClient" 
      android:label="@string/app_name" 
      android:theme="@android:style/Theme.Black.NoTitleBar" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

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

    </application> 

    <uses-sdk 
     android:minSdkVersion="8" 
     android:targetSdkVersion="18" /> 

</manifest> 

回答

0

打開科爾多瓦庫項目下面的Java文件

框架/ SRC /組織/阿帕奇/科爾多瓦/ CordovaWebView.java

替換以下行的代碼

if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)) 

if (url.startsWith("file://") || url.startsWith("javascript:") || Config.isUrlWhiteListed(url)&& !url.equals("about:blank")) 

它現在工作正常