Java 如何在IntentService中正确使用Volley库?

Java 如何在IntentService中正确使用Volley库?,java,android,android-volley,fatal-error,intentservice,Java,Android,Android Volley,Fatal Error,Intentservice,我对截击库有问题。我正在测试这个库,在三星S5上10分钟后收到错误 下面是我的简单示例代码: public class SimpleWakefulService extends IntentService { public SimpleWakefulService() { super("SimpleWakefulService"); } boolean success = true; JSONArray t = new JSONArray()

我对截击库有问题。我正在测试这个库,在三星S5上10分钟后收到错误

下面是我的简单示例代码:

public class SimpleWakefulService extends IntentService {

    public SimpleWakefulService() {
        super("SimpleWakefulService");
    }

    boolean success = true;

    JSONArray t = new JSONArray();
    JSONArray o = new JSONArray();
    JSONArray m = new JSONArray();

    @Override
    protected void onHandleIntent(Intent intent) {

        RequestQueue queue = Volley.newRequestQueue(this);

        StringRequest postRequest = new StringRequest(Request.Method.POST, PROT + "://" + REMOTE + "/" + DIR + "/repeat.php",
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {

                        try {
                            JSONObject result = new JSONObject(response);
                            success = result.getBoolean("success");
                            t = result.getJSONArray("t");
                            o = result.getJSONArray("o");
                            m = result.getJSONArray("m");
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        Intent intent = new Intent(getApplicationContext(), Zlecenia.class);
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                        startActivity(intent);

                        alarm();

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

                        searchsignal();

                    }
                }
        ) {
            @Override
            protected Map<String, String> getParams()
            {

                GlobalConfig config = new GlobalConfig();
                JSONObject json = config.getConfig();
                JSONObject location = config.getLocation();

                JSONObject data = new JSONObject();

                try {

                    data.put("ID", json.getString("ID"));
                    data.put("session", json.getString("session"));

                    if(location != null) {

                        data.put("latitude", location.getString("latitude"));
                        data.put("longitude", location.getString("longitude"));

                    }

                    if(Strefa.Tabela){
                        data.put("tabela", true);
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                Map<String, String>  params = new HashMap<String, String>();
                params.put("json", data.toString());

                return params;
            }

        };

        postRequest.setRetryPolicy(new DefaultRetryPolicy(
                5000,
                DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        queue.add(postRequest);

        SimpleWakefulReceiver.completeWakefulIntent(intent);

    }

    public void alarm() {

        Intent intent = new Intent(this, SimpleWakefulReceiver.class);
        GlobalConfig.pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
        GlobalConfig.alarmManager = (AlarmManager) this.getSystemService(ALARM_SERVICE);

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            GlobalConfig.alarmManager.setExact(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 3000, GlobalConfig.pendingIntent);
        } else {
            GlobalConfig.alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 3000, GlobalConfig.pendingIntent);
        }

    }

}
公共类SimpleWakefulService扩展了IntentService{
公共SimpleWakefulService(){
超级(“SimpleWakefulService”);
}
布尔成功=真;
JSONArray t=新的JSONArray();
JSONArray o=新的JSONArray();
JSONArray m=新的JSONArray();
@凌驾
受保护的手部内容无效(意图){
RequestQueue=Volley.newRequestQueue(this);
StringRequest postRequest=新的StringRequest(Request.Method.POST,PROT+“://”+REMOTE+“/”+DIR+“/repeat.php“,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串响应){
试一试{
JSONObject结果=新JSONObject(响应);
success=result.getBoolean(“success”);
t=result.getJSONArray(“t”);
o=result.getJSONArray(“o”);
m=result.getJSONArray(“m”);
}捕获(JSONException e){
e、 printStackTrace();
}
Intent Intent=新的Intent(getApplicationContext(),Zlecenia.class);
intent.setFlags(intent.FLAG_ACTIVITY_CLEAR_TASK | intent.FLAG_ACTIVITY_NEW_TASK);
星触觉(意向);
报警();
}
},
新的Response.ErrorListener(){
@凌驾
公共无效onErrorResponse(截击错误){
搜索信号();
}
}
) {
@凌驾
受保护的映射getParams()
{
GlobalConfig config=新的GlobalConfig();
JSONObject json=config.getConfig();
JSONObject location=config.getLocation();
JSONObject数据=新的JSONObject();
试一试{
data.put(“ID”,json.getString(“ID”);
data.put(“session”,json.getString(“session”);
如果(位置!=null){
data.put(“纬度”,location.getString(“纬度”);
data.put(“经度”,location.getString(“经度”);
}
if(Strefa.Tabela){
data.put(“tabela”,true);
}
}捕获(JSONException e){
e、 printStackTrace();
}
Map params=新的HashMap();
put(“json”,data.toString());
返回参数;
}
};
postRequest.setRetryPolicy(新的DefaultRetryPolicy(
5000,
DefaultRetryPolicy.DEFAULT\u最大重试次数,
DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
添加(postRequest);
SimpleWakefulReceiver.completeWakefulIntent(intent);
}
公众虚空警报(){
Intent Intent=新Intent(这是SimpleWakefulReceiver.class);
GlobalConfig.PendingEvent=PendingEvent.getBroadcast(this,0,intent,0);
GlobalConfig.alarmManager=(alarmManager)this.getSystemService(ALARM\u服务);
if(android.os.Build.VERSION.SDK\u INT>=android.os.Build.VERSION\u code.KITKAT){
GlobalConfig.alarmManager.setExact(alarmManager.RTC_唤醒,System.currentTimeMillis()+3000,GlobalConfig.PendingContent);
}否则{
GlobalConfig.alarmManager.set(alarmManager.RTC_唤醒,System.currentTimeMillis()+3000,GlobalConfig.PendingEvent);
}
}
}
我坐在屏幕上观察。我在等。。。我的空间变小,10分钟后看到错误:

03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/qdmemalloc: ion: Failed to map memory in the client: Out of memory
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/qdgralloc: Could not mmap handle 0x6210d100, fd=50 (Out of memory)
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/qdgralloc: gralloc_register_buffer: gralloc_map failed
03-15 13:36:29.121 10969-11275/com.example.seadog.gps W/GraphicBufferMapper: registerBuffer(0x6210d100) failed -12 (Out of memory)
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/GraphicBuffer: unflatten: registerBuffer failed: Out of memory (-12)
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/Surface: dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -12
03-15 13:36:29.121 10969-11275/com.example.seadog.gps W/Adreno-EGLSUB: <DequeueBuffer:720>: dequeue native buffer fail: Out of memory, buffer=0x0, handle=0x0
03-15 13:36:29.121 10969-11275/com.example.seadog.gps W/Adreno-EGL: <qeglDrvAPI_eglSwapBuffers:3702>: EGL_BAD_SURFACE
03-15 13:36:29.121 10969-11275/com.example.seadog.gps W/OpenGLRenderer: swapBuffers encountered EGL_BAD_SURFACE on 0x621739c0, halting rendering...
03-15 13:36:29.151 10969-11275/com.example.seadog.gps A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x54 in tid 11275 (RenderThread)
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/qdmemalloc:ion:映射客户端内存失败:内存不足
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/qdgralloc:无法处理mmap 0x6210d100,fd=50(内存不足)
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/qdgralloc:gralloc_寄存器_缓冲区:gralloc_映射失败
03-15 13:36:29.121 10969-11275/com.example.seadog.gps W/graphicsbuffermapper:registerBuffer(0x6210d100)失败-12(内存不足)
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/graphicsbuffer:unflatten:registerBuffer失败:内存不足(-12)
03-15 13:36:29.121 10969-11275/com.example.seadog.gps E/Surface:dequeueBuffer:igraphicsbufferproducer::requestBuffer失败:-12
03-15 13:36:29.121 10969-11275/com.example.seadog.gps W/Adreno EGLSUB::出列本机缓冲区失败:内存不足,缓冲区=0x0,句柄=0x0
03-15 13:36:29.121 10969-11275/com.example.seadog.gps W/Adreno EGL::EGL_BAD_SURFACE
03-15 13:36:29.121 10969-11275/com.example.seadog.gps W/OpenGLRenderer:swapBuffers在0x621739c0上遇到EGL_BAD_曲面,正在停止渲染。。。
03-15 13:36:29.151 10969-11275/com.example.seadog.gps A/libc:tid 11275中的致命信号11(SIGSEGV),代码1,故障地址0x54(渲染读取)