小编Ned*_*vid的帖子

尝试在空对象引用上调用虚拟方法“java.io.File android.content.Context.getCacheDir()”

我正在尝试使用 Volley 并在登录后发送 GET 请求以检查数据。
我有专门的“API”班级,所有 Volley 员工都在那里。
我想要做的是在 LoginActivity(默认 android studio 模板)中检查验证后,我想在 LoginActivity 中创建 API 实例并将 GET 请求发送到服务器。
这仅用于测试 Volley,稍后我想在某个 Main 类中创建一个 API 实例。

这是我的 API 类:

import android.app.Application;
import android.util.Log;

import com.android.volley.*;
import com.android.volley.toolbox.Volley;
import com.android.volley.toolbox.JsonObjectRequest;
import org.json.JSONObject;
import java.lang.String;

public class API extends Application {

    protected String ServerURL;
    protected String GET;
    protected String POST;
    protected RequestQueue queue;

    public API(){
        setServerURL("http://localhost:63424");
        setGET("http://localhost:63424/api");
        setPOST("http://localhost:63424/api");
        queue = Volley.newRequestQueue(this);
    }

    protected void SendGET (String request)
    {
        JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, …
Run Code Online (Sandbox Code Playgroud)

android nullpointerexception android-volley

1
推荐指数
1
解决办法
9561
查看次数