Android Question failure at IF statement

Baris Karadeniz

Active Member
Licensed User
I am sure solution is very basic but I need to ask. I use if statement and it gives a failure. I couldn't find the solution. What can be the reason for failure?

Codes are;

B4X:
If (WebViewMap.Url = "http://www.xxx.com") And CanGoBack(WebViewMap) Then  <--- Line 533
     WebViewMap.Back  
End if

End Sub

Error log;

** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
JobName = Job2, Success = true
0
JobName = MyJob, Success = true
Error occurred on line: 533 (Main)
java.lang.NullPointerException
at app.taksim.driver.main._activity_keypress(main.java:767)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:702)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:336)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at app.taksim.driver.main$HandleKeyDelayed.runDirectly(main.java:226)
at app.taksim.driver.main$HandleKeyDelayed.run(main.java:223)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Pause, UserClosed = true **
 

gerredtor

Active Member
Licensed User
try this:

B4X:
if WebViewMap.Url == null Then
log("URL = null")
return
End if

if CanGoBack(WebViewMap) == null Then
log("CANGOBACK = null")
return
End if

If (WebViewMap.Url = "http://www.xxx.com") And CanGoBack(WebViewMap) Then <--- Line 533
WebViewMap.Back
End if
End Sub

and look at the log
 
Upvote 0
Top