我正在寻找一个如何在PhoneGap和Android中使用OpenStreetMap的示例.
我在网上找到了一些旧的例子,例如http://mab.edina.ac.uk/geomobile-test/osm.html,但它没有使用最新的PhoneGap,我按照PhoneGap的教程.
的Manifest.xml:
主要课程:
package de.h3llghost.phonegap.test; import android.os.Bundle; import com.phonegap.DroidGap; public class PhoneGapTestActivity extends DroidGap { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.loadUrl("file:///android_asset/www/index.html"); // Doesn't work there is something wrong with the timeout in PhoneGap //super.loadUrl("file:///android_asset/www/index.html", 50000); } }
index.html的:
SimpleIOL Demo: IOL
我得到了以下错误,也许有人让它运行(修复):
11-11 21:29:46.210: D/DroidGap(871): DroidGap.loadUrl(file:///android_asset/www/index.html, 50000) 11-11 21:30:36.273: D/DroidGap(871): DroidGap.loadUrl(file:///android_asset/www/index.html) 11-11 21:30:36.273: D/DroidGap(871): DroidGap.init() 11-11 21:30:36.273: W/dalvikvm(871): threadid=7: thread exiting with uncaught exception (group=0x4001d800) 11-11 21:30:36.280: E/AndroidRuntime(871): FATAL EXCEPTION: Thread-8 11-11 21:30:36.280: E/AndroidRuntime(871): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 11-11 21:30:36.280: E/AndroidRuntime(871): at android.os.Handler.(Handler.java:121) 11-11 21:30:36.280: E/AndroidRuntime(871): at android.webkit.WebView$PrivateHandler. (WebView.java:6252) 11-11 21:30:36.280: E/AndroidRuntime(871): at android.webkit.WebView. (WebView.java:395) 11-11 21:30:36.280: E/AndroidRuntime(871): at android.webkit.WebView. (WebView.java:920) 11-11 21:30:36.280: E/AndroidRuntime(871): at android.webkit.WebView. (WebView.java:910) 11-11 21:30:36.280: E/AndroidRuntime(871): at android.webkit.WebView. (WebView.java:901) 11-11 21:30:36.280: E/AndroidRuntime(871): at com.phonegap.DroidGap.init(DroidGap.java:268) 11-11 21:30:36.280: E/AndroidRuntime(871): at com.phonegap.DroidGap.loadUrlIntoView(DroidGap.java:381) 11-11 21:30:36.280: E/AndroidRuntime(871): at com.phonegap.DroidGap.access$300(DroidGap.java:159) 11-11 21:30:36.280: E/AndroidRuntime(871): at com.phonegap.DroidGap$3.run(DroidGap.java:537) 11-11 21:30:36.280: E/AndroidRuntime(871): at java.lang.Thread.run(Thread.java:1096)
感谢您的任何建议.
当我删除50000并且只将一个参数传递给loadUrl时,崩溃就消失了.似乎1.2中的timeout参数可能存在问题.