• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Sending Get Requests to a site using Volley

D

Deleted User

Guest
I'm trying to make an android application that retrieves information from a sever and returns it in a list. The server has it's own api for retrieving information

Code:
GET /xxxx/xxx.json?xxx=0104529

I've seen the example provided by google:

Java:
    RequestQueue queue = Volley.newRequestQueue(this);
    String url ="http://www.google.com";

    // Request a string response from the provided URL.
    StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
            new Response.Listener<String>() {
    @Override
    public void onResponse(String response) {
        // Display the first 500 characters of the response string.
        mTextView.setText("Response is: "+ response.substring(0,500));
    }
    }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
        mTextView.setText("That didn't work!");
    }
    });
    // Add the request to the RequestQueue.
    queue.add(stringRequest);

And I somewhat understand it, however I'm having a hard time figuring out how to use the sites own get api with the example above, and also how to parse m result into a list

I'm sorry if I'm not making much sense, the only experience I have with this was writing a script for battle snake that had the following lines

Code:
  @bottle.post('/move')
    def move(self):
        data = bottle.request.json

with this I could access information like this

Code:
ourSnakeX = data['snakes'[0]['coords'][0][0]]

I'm looking for a way to do that with an android application. I have the data url and the api for the site, I just don't know how to access it. I'm coding in Java. Thank you in advance
 
  • Like
Reactions: mahmdkurdi36

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones