Android Open Source - GPSTracker Transport






From Project

Back to project page GPSTracker.

License

The source code is released under:

MIT License

If you think the Android project GPSTracker listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.creyon.gpstracker;
//from  www.  j  a v a 2  s.  c o  m
import java.util.Map;

import android.content.Context;
import android.util.Log;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
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 Transport {

  private static  Transport instance = null;

  private static RequestQueue reQ;

   public Transport(Context context) {
    reQ = (this.reQ == null) ? Volley.newRequestQueue(context) : this.reQ;
  }

  /**
   *  Asynchronous call to the server  
   * 
   * **/
  public Transport sendMessage(final Message msg){
    Log.e("tracker","intentando enviar data : "+ msg.toPackage().toString());
    StringRequest postReq = new StringRequest(Request.Method.POST, GlobalData.URL_SERVER , new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
           Log.e("Transport","response successed : "+ response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
          Log.e("Transport","response failed "+ error);
            System.out.println("Error ["+error+"]");
        }
    }){
      @Override
      protected Map<String, String> getParams()
          throws AuthFailureError {
        return  msg.toPackage();
      }
    };
    reQ.add(postReq);    
    return this;
  }

}




Java Source Code List

com.creyon.gpstracker.GlobalData.java
com.creyon.gpstracker.Message.java
com.creyon.gpstracker.StarterActivity.java
com.creyon.gpstracker.Tracker.java
com.creyon.gpstracker.Transport.java
com.creyon.gpstracker.Trigger.java