Android Question B4A: GPS

Husain Ragib

Member
Licensed User
With the GPS example, I could get the information only when I am outside. Won't it fetch the details indoor? The GPS app in my mobile shows the location even if I am inside. Isn't there any way to get my location indoor?
 

Husain Ragib

Member
Licensed User
Thank you Euro for your reply.

I have a query while accesing web service.

I am accessing my Email sending webservice in b4a.

In Process_Globals funtion, I have declared the following with my public webservice url defined in PostUrl string
Dim HttpClient1 As OkHttpClient
Dim PostUrl As String

I have initialised my httpclient in Activity_Create if FirstTime
HttpClient1.Initialize("HttpClient1")

Then in my scenario where i want to send email, I am executing the request as follows:
Dim request As OkHttpRequest
request.InitializeGet(PostUrl)
request.Timeout = 100000 'set timeout to 10 seconds
If HttpClient1.Execute(request, 1) = False Then Return 'Will be false if their is already a running task (with the same id).
ProgressDialogShow("Sending Email...")

I have also used the Success and Error event for getting response as follows.

Sub HttpClient1_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
Log("ResponseSuccess")
ProgressDialogHide
End Sub

Sub HttpClient1_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
Log(Reason)
Log(StatusCode)
ProgressDialogHide

Dim msg As String
msg = "Error connecting to server."
If Reason <> Null Then msg = msg & CRLF & Reason
ToastMessageShow (msg, True)
End Sub

When I try to send email, eventhough my response is a sucess, I am not receiving any emails. Can you please help me on this.
Also, If I need to pass parameters to my webservice, how can I acheive the same?

I tried the above using HttpClient instead of OkHttpClient, but i am getting below exception
If HttpClient1.Execute(request, 1) = False Then
javac 1.8.0_76-release
src\b4a\EnTrackBLE\actmonitor.java:405: error: cannot access ClientProtocolException
if (_httpclient1.Execute(processBA,_request,(int) (1))==anywheresoftware.b4a.keywords.Common.False) {
^
class file for org.apache.http.client.ClientProtocolException not found
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
Husain,
please use the code Tags or the code Tool - see image - then your question will be much more easier to read....
Image1.png
 
Upvote 0

Husain Ragib

Member
Licensed User
  1. I am accessing my Email sending webservice in b4a.

    In Process_Globals funtion, I have declared the following with my public webservice url defined in PostUrl string
    B4X:
    Dim HttpClient1 As OkHttpClient
    Dim PostUrl As String

    I have initialised my httpclient in Activity_Create if FirstTime
    B4X:
    HttpClient1.Initialize("HttpClient1")

    Then in my scenario where i want to send email, I am executing the request as follows:
    B4X:
    Dim request As OkHttpRequest
    request.InitializeGet(PostUrl)
    request.Timeout = 100000 'set timeout to 10 seconds
    If HttpClient1.Execute(request, 1) = False Then Return 'Will be false if their is already a running task (with the same id).
    ProgressDialogShow("Sending Email...")


    I have also used the Success and Error event for getting response as follows.
    B4X:
    Sub HttpClient1_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
    Log("ResponseSuccess")
    ProgressDialogHide
    End Sub

    B4X:
    Sub HttpClient1_ResponseError (Reason As String, StatusCode As Int, TaskId As Int)
    Log(Reason)
    Log(StatusCode)
    ProgressDialogHide
    
    Dim msg As String
    msg = "Error connecting to server."
    If Reason <> Null Then msg = msg & CRLF & Reason
    ToastMessageShow (msg, True)
    End Sub

    When I try to send email, even though my response is a success, I am not receiving any emails. Can you please help me on this.
    Also, If I need to pass parameters to my web service, how can I achieve the same?

    I tried the above using
    HttpClient
    instead of
    OkHttpClient
    , but i am getting exception:
    If HttpClient1.Execute(request, 1) = False Then
    1. javac 1.8.0_76-release
      src\b4a\EnTrackBLE\actmonitor.java:405: error: cannot access ClientProtocolException
      if (_httpclient1.Execute(processBA,_request,(int) (1))==anywheresoftware.b4a.keywords.Common.False) {
      ^
      class file for org.apache.http.client.ClientProtocolException not found
 
Upvote 0
Top