我在Android中有一个混合应用程序,它也涉及本机功能:
带有javascript的HTML 5:
<html>
<head>
<script src="jquery-1.5.1.min.js"></script>
<script src="menus.js"></script>
<script src="jquery-ui-1.8.10.custom.min.js"></script>
<script type="text/javascript">
function openCamera1(){
camera.startCameraActivity1();
var path1=camera.getImagePath1();
alert(path1);
document.getElementById("image1").src=path1;
}
function openCamera2(){
camera.startCameraActivity2();
var path2=camera.getImagePath2();
alert(path2);
document.getElementById("image2").src=path2;
}
function show_confirm() {
var r=confirm("Do you wish to use the existing Details?");
if (r==true)
{
alert("You pressed OK!");
} else {
alert("You pressed Cancel!");
}
}
in html:
<input type="button" onclick="show_confirm()" value="Register Cliam" />
java中的:( android native):
public String getDetails(){
System.out.println("iiiiiiiiiiiiiiii");
String a=dh.hello();
System.out.println("aaaaaaaaaaaa " + a);
return a;
}
数据助手类:
public String hello(){
return "Hello";
}
我面临的例外情况:
12-19 09:19:57.894: WARN/dalvikvm(718): JNI WARNING: JNI method called with exception raised
12-19 09:19:57.894: WARN/dalvikvm(718): in Landroid/webkit/WebViewCore;.nativeTouchUp (IIIII)V (NewGlobalRef)
12-19 09:19:57.894: WARN/dalvikvm(718): Pending exception is:
12-19 09:19:57.894: INFO/dalvikvm(718): Ljava/lang/NullPointerException;:
12-19 09:19:57.894: INFO/dalvikvm(718): at com.test.hybrid.aviva.OpenCamera.getDetails(OpenCamera.java:179)
12-19 09:19:57.894: INFO/dalvikvm(718): at android.webkit.WebViewCore.nativeTouchUp(Native Method)
12-19 09:19:57.894: INFO/dalvikvm(718): at android.webkit.WebViewCore.access$3400(WebViewCore.java:48)
12-19 09:19:57.905: INFO/dalvikvm(718): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1094)
12-19 09:19:57.925: INFO/dalvikvm(718): at android.os.Handler.dispatchMessage(Handler.java:99)
12-19 09:19:57.925: INFO/dalvikvm(718): at android.os.Looper.loop(Looper.java:123)
12-19 09:19:57.925: INFO/dalvikvm(718): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:611)
12-19 09:19:57.925: INFO/dalvikvm(718): at java.lang.Thread.run(Thread.java:1096)
12-19 09:19:57.925: INFO/dalvikvm(718): "WebViewCoreThread" prio=5 tid=15 NATIVE
12-19 09:19:57.934: INFO/dalvikvm(718): | group="main" sCount=0 dsCount=0 s=N obj=0x44c13848 self=0x139858
12-19 09:19:57.934: INFO/dalvikvm(718): | sysTid=725 nice=0 sched=0/0 cgrp=default handle=1284464
12-19 09:19:57.934: INFO/dalvikvm(718): at android.webkit.WebViewCore.nativeTouchUp(Native Method)
12-19 09:19:57.934: INFO/dalvikvm(718): at android.webkit.WebViewCore.nativeTouchUp(Native Method)
12-19 09:19:57.934: INFO/dalvikvm(718): at android.webkit.WebViewCore.access$3400(WebViewCore.java:48)
12-19 09:19:57.934: INFO/dalvikvm(718): at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1094)
12-19 09:19:57.934: INFO/dalvikvm(718): at android.os.Handler.dispatchMessage(Handler.java:99)
12-19 09:19:57.934: INFO/dalvikvm(718): at android.os.Looper.loop(Looper.java:123)
12-19 09:19:57.955: INFO/dalvikvm(718): at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:611)
12-19 09:19:57.955: INFO/dalvikvm(718): at java.lang.Thread.run(Thread.java:1096)
12-19 09:19:57.955: ERROR/dalvikvm(718): VM aborting
答案 0 :(得分:1)
非常怀疑
String a=dh.hello();
dh为空。