------索引.html
<!DOCTYPE HTML>
<html>
<head>
<title>AmmoAmmo</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script
src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
<script type="text/javascript" charset="utf-8" src="samin.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad() {
console.log("1.......onLoad()...........");
document.addEventListener("deviceready", onDeviceReady(), false);
}
// Cordova is loaded and it is now safe to make calls Cordova methods
//
function onDeviceReady() {
console.log("2. -------------onDeviceReady--------------------");
// Now safe to use the Cordova API
alert('3. _____________onDeviceReady()-DONE!_____________');
}
function saveAmmo(value){
//testAlert();
window.localStorage.setItem("selectedAmmo", value);
alert(value,'_top');
}
</script>
</head>
<body onload="onLoad()">
<div data-role="page" id="homePage" data-theme="a">
<div data-role="header">
<a href="index.html" data-icon="info">Help</a>
<h1>Testing</h1>
<a href="contact.html" data-icon="info">Contact</a>
</div>
<div data-role="content">
<p>
<label for="select-choice-0" class="select"></label>
<select name="select-choice-0" id="select-choice-0"
data-mini="true" onchange="saveAmmo(this.options[this.selectedIndex].value)">
<option value='null' SELECTED>Select a Ammo</option>
<option value='1' >111</option>
<option value='2' >222</option>
</select>
</p>
</div>
<div class="ui-grid-a">
<div class="ui-block-a" align="center">
<img src="images/22-250_rem_1.jpeg" data-theme="c"/>
</div>
<div class="ui-block-b" align="center">
<img src="images/22-250_rem_1.jpeg" data-theme="c"/>
</div>
</div>
<div data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="index.html" class="ui-btn-
active">Ammo</a></li>
<li><a href="testing1.html">Test1</a></li>
<li><a href="testing2.html">Test2</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
这与 Cordova 文档中的情况完全相同:http: //docs.phonegap.com/en/1.9.0/cordova_events_events.md.html#deviceready
其他一切都在工作,但这将成为一个真正的阻碍,因为我在从本地存储读取数据时需要它。我应该相信这些文件吗?
--------插件.xml:
<plugins>
<plugin name="App" value="org.apache.cordova.App"/>
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
<plugin name="Device" value="org.apache.cordova.Device"/>
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
<plugin name="Compass" value="org.apache.cordova.CompassListener"/>
<plugin name="Media" value="org.apache.cordova.AudioHandler"/>
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
<plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
<plugin name="File" value="org.apache.cordova.FileUtils"/>
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
<plugin name="Notification" value="org.apache.cordova.Notification"/>
<plugin name="Storage" value="org.apache.cordova.Storage"/>
<plugin name="Temperature" value="org.apache.cordova.TempListener"/>
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
<plugin name="Capture" value="org.apache.cordova.Capture"/>
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
--------Manifest.xml---------
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycordova.hellocordova"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true" />
<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.READ_PHONE_STATE" />
<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.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:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".HelloCordovaActivity"
android:label="@string/title_activity_hello_cordova"
android:configChanges="orientation|keyboardHidden|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
--------Activity.java----------
package com.mycordova.hellocordova;
import android.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import org.apache.cordova.*;
public class HelloCordovaActivity extends DroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
- - - - 日志:
07-16 10:23:12.878: D/DroidGap(637): onMessage(onPageStarted,file:///android_asset/www/index.html)
07-16 10:23:13.848: D/chromium(637): Unknown chromium error: -6
07-16 10:23:22.388: D/CordovaLog(637): 1.......onLoad()...........
07-16 10:23:22.388: D/CordovaLog(637): file:///android_asset/www/index.html: Line 16 : 1.......onLoad()...........
07-16 10:23:22.398: I/Web Console(637): 1.......onLoad()........... at file:///android_asset/www/index.html:16
07-16 10:23:22.398: D/CordovaLog(637): 2. -------------onDeviceReady--------------------
07-16 10:23:22.408: D/CordovaLog(637): file:///android_asset/www/index.html: Line 23 : 2. -------------onDeviceReady--------------------
07-16 10:23:22.408: I/Web Console(637): 2. -------------onDeviceReady-------------------- at file:///android_asset/www/index.html:23
07-16 10:23:22.789: I/Choreographer(637): Skipped 44 frames! The application may be doing too much work on its main thread.
07-16 10:23:31.608: E/CordovaWebView(637): CordovaWebView: TIMEOUT ERROR!
07-16 10:23:31.608: D/Cordova(637): CordovaWebViewClient.onReceivedError: Error code=-6 Description=The connection to the server was unsuccessful. URL=file:///android_asset/www/index.html
07-16 10:23:31.638: D/DroidGap(637): onMessage(onReceivedError,{"errorCode":-6,"url":"file:\/\/\/android_asset\/www\/index.html","description":"The connection to the server was unsuccessful."})
07-16 10:23:31.869: I/Choreographer(637): Skipped 55 frames! The application may be doing too much work on its main thread.
07-16 10:23:31.869: D/SoftKeyboardDetect(637): Ignore this event
07-16 10:23:31.995: D/dalvikvm(637): GC_CONCURRENT freed 236K, 4% free 8186K/8519K, paused 27ms+64ms, total 279ms
07-16 10:23:32.788: I/Choreographer(637): Skipped 128 frames! The application may be doing too much work on its main thread.
07-16 10:26:00.398: D/DroidGap(637): onDestroy()
07-16 10:26:00.398: D/CordovaWebView(637): >>> loadUrlNow()
07-16 10:26:00.398: D/CordovaWebView(637): >>> loadUrlNow()
07-16 10:26:00.489: E/WindowManager(637): Activity com.mycordova.hellocordova.HelloCordovaActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41232338 that was originally added here
07-16 10:26:00.489: E/WindowManager(637): android.view.WindowLeaked: Activity com.mycordova.hellocordova.HelloCordovaActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@41232338 that was originally added here
07-16 10:26:00.489: E/WindowManager(637): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:374)
07-16 10:26:00.489: E/WindowManager(637): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292)
07-16 10:26:00.489: E/WindowManager(637): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
07-16 10:26:00.489: E/WindowManager(637): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
07-16 10:26:00.489: E/WindowManager(637): at android.view.Window$LocalWindowManager.addView(Window.java:547)
07-16 10:26:00.489: E/WindowManager(637): at android.app.Dialog.show(Dialog.java:277)
07-16 10:26:00.489: E/WindowManager(637): at android.app.AlertDialog$Builder.show(AlertDialog.java:932)
07-16 10:26:00.489: E/WindowManager(637): at org.apache.cordova.CordovaChromeClient.onJsAlert(CordovaChromeClient.java:120)
07-16 10:26:00.489: E/WindowManager(637): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:572)
07-16 10:26:00.489: E/WindowManager(637): at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 10:26:00.489: E/WindowManager(637): at android.os.Looper.loop(Looper.java:137)
07-16 10:26:00.489: E/WindowManager(637): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-16 10:26:00.489: E/WindowManager(637): at java.lang.reflect.Method.invokeNative(Native Method)
07-16 10:26:00.489: E/WindowManager(637): at java.lang.reflect.Method.invoke(Method.java:511)
07-16 10:26:00.489: E/WindowManager(637): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-16 10:26:00.489: E/WindowManager(637): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-16 10:26:00.489: E/WindowManager(637): at dalvik.system.NativeStart.main(Native Method)
干杯,萨米