No step by step tutorials ?

kikloo

Member
Licensed User
Longtime User
Hi,

I just configured B4A and did the hello world tutorial. Now what ? Why the tutorials are not stacked step by step ? I am clicking on other tutorials and I don't even know where to begin. :confused:

Please stack tutorials step by step, so a new user gets familiar with the software and working of the whole thing. I am not even understand some stuff in some of the tutorials eg.

in some tutorial it says: Add layout file (How ???!!!! ) :confused:
in GPS tutorial it says:

"The GPS functionality is packaged in the GPS library.
Therefore we should first add a reference to this library:"

How ???!!! :confused:

Please organize the tutorials step by step!!

Thanks.
 

kikloo

Member
Licensed User
Longtime User
Hi,

I made the Math Trainer program.
Now i know a bit how the B4A works.

My next question: How to make requests using REST API and process the returned JSON data and show it in elements ? Is there any tutorial for that ?

Thanks.
 
Upvote 0

manios

Active Member
Licensed User
Longtime User
REST very much depends on the on the information the server expects or supplies, I dont think someone can make a general tutor.
Try the search box in the upper right hand corner. Enter - rest -, you will get 7 pages with a lot of information on the subject!
 
Upvote 0

kikloo

Member
Licensed User
Longtime User
Hi,

I just want to send the query like this: index.php?somevar=somevalue&somevar=somevalue

Then the server will send the response as JSON that I have to process and display on mobile. How to achieve that ?

Is there any basic tutorial which tell me how to send the request and get the response ?

:sign0085:

Thanks.
 
Upvote 0

dr3d

New Member
Licensed User
Longtime User
Hey I'm a noob too. And I don't expect to understand everything in a day. The Beginners Guide really IS the user manual - you need to spend time with that.

Anyway, hopefully these snippets show how to get working with a RESTful webservice.. I just figured this out yesterday, so may have a detail wrong - but you get the idea:

B4X:
Sub Globals
    ' webservice url is global
    Dim url As String
    url = ...
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ' need to use HttpUtils module - download that
    HttpUtils.CallbackActivity = "Main"
    HttpUtils.CallbackJobDoneSub = "JobDone"
    HttpUtils.Download("Index", url)
End Sub

Sub JobDone(Job As String)
    ' Completion function for when the download completes:

    If HttpUtils.IsSuccess(url) == False Then Return

    ' JSON parsing
    Dim parser As JSONParser
    parser.Initialize(HttpUtils.GetString(url))

    ' Choose one:

    ' If what's returned is a list of items:
    Dim items As List
    items = parser.NextArray

    ' OR if what's returned is an object:
    Dim item as Map
    item = parser.NextObject

     ' from this point forward use the item.Get() functions to access elements or fields
End Sub
 
Upvote 0

kikloo

Member
Licensed User
Longtime User
Hey I'm a noob too. And I don't expect to understand everything in a day. The Beginners Guide really IS the user manual - you need to spend time with that.

Anyway, hopefully these snippets show how to get working with a RESTful webservice.. I just figured this out yesterday, so may have a detail wrong - but you get the idea:

B4X:
Sub Globals
    ' webservice url is global
    Dim url As String
    url = ...
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ' need to use HttpUtils module - download that
    HttpUtils.CallbackActivity = "Main"
    HttpUtils.CallbackJobDoneSub = "JobDone"
    HttpUtils.Download("Index", url)
End Sub

Sub JobDone(Job As String)
    ' Completion function for when the download completes:

    If HttpUtils.IsSuccess(url) == False Then Return

    ' JSON parsing
    Dim parser As JSONParser
    parser.Initialize(HttpUtils.GetString(url))

    ' Choose one:

    ' If what's returned is a list of items:
    Dim items As List
    items = parser.NextArray

    ' OR if what's returned is an object:
    Dim item as Map
    item = parser.NextObject

     ' from this point forward use the item.Get() functions to access elements or fields
End Sub

Hi,

I tried http://www.b4x.com/forum/basic4andr...-connect-android-mysql-database-tutorial.html and its working.

1. Please ignore my earlier comment. Just wanted to clarify, that I am trying to load first categories and then when user clicks on categories the respective subcategories show. Now should i create different layout, listview for categories and subcategories or should I use in single layout, listview ?

2. Again, maybe dumb on my part but where to find httputils library ? Can't seem to find it anywhere.

Thanks.
 
Last edited:
Upvote 0

kikloo

Member
Licensed User
Longtime User
Hi,

I am trying it now with httputils, but it does'nt seems to be doing anything. I am suppose to get a message box saying: "\nQuery was empty".

Whats wrong with my code ?

B4X:
Sub Process_Globals
   Dim api_url As String
   api_url= "http://127.0.0.1/android/index.php"
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Dim ListView1 As ListView
   
   HttpUtils.CallbackActivity = "Main"
    HttpUtils.CallbackJobDoneSub = "JobDone"
    HttpUtils.Download("Categories", api_url)   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub JobDone (Job As String)
   If HttpUtils.IsSuccess(api_url) == False Then Return

   Msgbox (HttpUtils.GetString(api_url), "Result")
End Sub

It seems to be self explaning but does'nt seems to be doing anything. No errors etc.

Thanks
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Is the program getting to job done? Try taking out this line
B4X:
    If HttpUtils.IsSuccess(api_url) == False Then Return
and see if the message is displayed
 
Upvote 0

kikloo

Member
Licensed User
Longtime User
Is the program getting to job done? Try taking out this line
B4X:
    If HttpUtils.IsSuccess(api_url) == False Then Return
and see if the message is displayed

Hi,

I got it, the connection was being refused to 127.0.0.1 so I uploaded to my webspace and now its working.

Thanks.
 
Upvote 0
Top