使用凌空时我无法从服务器获得任何响应?

时间:2015-03-20 07:23:57

标签: android android-volley android-intentservice

我正在使用volley从服务器获取具有意向服务的响应,但无法从服务器获取响应。 Intent服务每次都在调用,但响应没有从服务器获取。 这是我的代码意图服务与volley: -

public class SampleSchedulingService extends IntentService {

String BASE_URL = "http://192.168.1.125:8080/";
String REG_CHECK = BASE_URL + "" + "services/account/check";

/**
 * @param name
 */
public SampleSchedulingService() {
    super("MYSCHEDULINGSERVICE");
    // TODO Auto-generated constructor stub
}

/* (non-Javadoc)
 * @see android.app.IntentService#onHandleIntent(android.content.Intent)
 */
@Override
protected void onHandleIntent(Intent intent) {
    // TODO Auto-generated method stub
    //Log.d(getClass().getSimpleName(), "I ran!");
    updateLatLong();

    //SampleAlarmReceiver.completeWakefulIntent(intent);
}

/**
 * 
 */
private void updateLatLong() {
    // TODO Auto-generated method stub
    HashMap<String, String> params = new HashMap<String, String>();

    params.put("imeiNo", "myImeiNumber");

    Log.d(getClass().getSimpleName(), params.toString());

    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
            VolleyHelper.POST, REG_CHECK,
            new JSONObject(params), onJsonObjectReqResponse(), null);
    ApplicationController.getInstance()
            .addToRequestQueue(jsonObjectRequest);
}

/**
 * @return
 */
private Response.Listener<JSONObject> onJsonObjectReqResponse() {
    // TODO Auto-generated method stub
    return new Response.Listener<JSONObject>() {

        @Override
        public void onResponse(JSONObject response) {
            // TODO Auto-generated method stub
            try {
                Log.d(getClass().getSimpleName(), response.toString());
            } catch (Exception e) {
                // TODO: handle exception
            }               
        }
    };
}   

}

0 个答案:

没有答案
相关问题