我使用下面的鏈接how to get back to android activity page from webviewVM開始新的活動
的解決方案可完美dispaly只有吐司消息時中止..
但這裏IM所面臨的問題是後,當嘗試啓動新活動吐司消息即時獲取虛擬機中止錯誤消息。
public class JavaScriptInterface{
Context mContext;
/** Instantiate the interface and set the context */
JavaScriptInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
@JavascriptInterface
public void showToast(String toast) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
menuScreenActivity menu=new menuScreenActivity();
menu.logout();//here i try to call the logut method
}
}
在menuScreenActivity活動
我在menuScreenActivity創建方法稱爲註銷
方法
public void logout(){
Intent myIntent= new Intent(menuScreenActivity.this,LoginActivity.class);
startActivity(myIntent);
}
我的日誌貓說
JNI WARNING: jarray 0x405a2478 points to non-array object (Ljava/lang/String;)
"WebViewCoreThread" prio=5 tid=9 NATIVE
| group="main" sCount=0 dsCount=0 obj=0x4058d718 self=0x1fecb0
| sysTid=746 nice=0 sched=0/0 cgrp=default handle=5148120
| schedstat=(23519331303 11309830622 1216)
at android.webkit.WebViewCore.nativeTouchUp(Native Method)
at android.webkit.WebViewCore.nativeTouchUp(Native Method)
at android.webkit.WebViewCore.access$3300(WebViewCore.java:53)
at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629)
at java.lang.Thread.run(Thread.java:1019)
VM aborting
請讓我知道如何解決這個問題?
ahah我沒有看到它!你可能是對的。不要用新的創建活動... – VinceFR
@iagreen startActivity(myIntent);這裏即時獲取錯誤,因爲方法startActivity(myIntent)未定義爲類型JavaScriptInterface – Sathish
您的JavaScriptInterface是一個活動的內部類嗎? – iagreen