Re: Android Studio + Volley, Request Queue Issue

687 views
Skip to first unread message

Evan Charlton

unread,
Jan 10, 2015, 11:29:46 AM1/10/15
to Patrick Bethell, volley...@googlegroups.com
According to your pasted snippet, none of the code is within a method. Presumably you meant to enclose it all within onCreate()?

Evan

On Sat, Jan 10, 2015 at 4:56 AM, Patrick Bethell <pat...@umbetas.com> wrote:
Hi,

After a while of fighting with Android Studio and Volley on a mac I got it to import and almost working.

When creating my new activity to test volley everything goes well until I attempt to add the the request to the queue.

Android Studio highlights that line and says that it can not resolve symbol 'add';

If I try to make my project with that line Gradle's errors are saying:
"Error:(39, 11) error: <identifier> expected" pointing to the parameter for the add method.



Mind taking a look to see if there is something I missed please? If you point me to another tutorial to read help me find it myself that would be great,



My code:

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.Toast;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

public class NetTest extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nettest);
    }

    RequestQueue rq = Volley.newRequestQueue(this);

    String url = "test.com";
    StringRequest request = new StringRequest(url,new Response.Listener<String>() {
        @Override
        public void onResponse(String s) {

        }
    },new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {

        }
    });

    rq.add(request);

}





--
You received this message because you are subscribed to the Google Groups "Volley Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to volley-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages