Android Question Add google doc url to bbview

I am using bbview named gdoclink. I pass the google webapp url to the following function:
B4X:
Sub hitAPI (url As String)
    Dim job As HttpJob
    pb.Visible=True
    'logoProgress("start")
    job.Initialize("",Me)
    job.Download(url)
    Wait for (job) JobDone(job As HttpJob)
    'logoProgress("stop")
    If job.Success Then
        pb.Visible=False
      [B]  Log(job.GetString)
        gdoclink.Text=$"[url=${job.GetString}]Google Doc Report[/url]"$[/B]
        gdoclink.mBase.Visible=True
    Else
        Log(job.ErrorMessage)
    End If
    job.Release    
End Sub
I get null object reference error in the highlighted line.although I get the google doc url in logger:

Error occurred on line: 93 (BBLabel)
java.lang.NullPointerException: Attempt to invoke virtual method 'anywheresoftware.b4a.objects.collections.List com.druma.leadeshipcompetency.bbcodeparser._parse(com.druma.leadeshipcompetency.bbcodeparser, com.druma.leadeshipcompetency.bbcodeparser$_bbcodeparsedata)' on a null object reference
at com.druma.leadeshipcompetency.bblabel._parseanddraw(bblabel.java:141)
at com.druma.leadeshipcompetency.bblabel._settext(bblabel.java:69)
at com.druma.leadeshipcompetency.b4xmainpage$ResumableSub_hitAPI.resume(b4xmainpage.java:665)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
at anywheresoftware.b4a.BA$2.run(BA.java:395)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:211)
at android.os.Looper.loop(Looper.java:300)
at android.app.ActivityThread.main(ActivityThread.java:8432)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:560)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:954)
Please help!
 
Solution
BBLabel doesn't expose this event. You need to use BBCodeView.

You should then handle the LinkClicked event and open it with:
B4X:
Dim in As Intent
in.Initialize(in.ACTION_VIEW, url)
StartActivity(in)
I wasn't aware that BCTextEngine too had to be declared and initialized to use bblabel.
Now I get the google doc's link in the code
B4X:
gdoclink.Text=$"[url=${job.GetString}]Google Doc Report[/url]"$[/B]
However it isn't 'clickable '. I expected the link to open the google doc. How to make the hyperlink open the google doc?
thanks
 
Upvote 0
Thank you. Good to know about BBCode View.
In this particular app prototype, I already used the long click event of a label:
B4X:
Private Sub lblGoogledoc_LongClick
    Dim ph As PhoneIntents       
    Dim i As Intent
    i = ph.OpenBrowser(gdocurl)
    StartActivity(i)
End Sub
 
Upvote 0
Top