Android Question App crash when ever post request made

IamTrying

Active Member
Licensed User
App keep crashing when post request is made.

B4X:
Sub btnPlay2_Click
    Log(">>> btnPlay2_Click")
  
    myLoginUrl = "https://xxx.xxx.com/app/splogin"
    job1.PostString(myLoginUrl, "username=xxx&password=1234&play=clip1")
  
End Sub

ERROR:

B4X:
Logger connected to:  samsung SM-G900F

>>> btnPlay2_Click
Error occurred on line: 64 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpRequest.InitializePost2(java.lang.String, byte[])' on a null object reference
    at anywheresoftware.b4a.samples.httputils2.httpjob._postbytes(httpjob.java:281)
    at anywheresoftware.b4a.samples.httputils2.httpjob._poststring(httpjob.java:420)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22433)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6186)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Always create a new Request
B4X:
Sub btnPlay2_Click
    Log(">>> btnPlay2_Click")
   dim job as httpjob
   job,initialize("login",me)   
    myLoginUrl = "https://xxx.xxx.com/app/splogin"
    job1.PostString(myLoginUrl, "username=xxx&password=1234&play=clip1")
  
End Sub
 
Upvote 0
Top