As leis da União Europeia exigem que você informe os visitantes da UE sobre os cookies usados e os dados coletados no seu blog.
Em muitos casos, essas leis também exigem que você tenha o consentimento deles.
home
Android Studio
Aide

Cambio [ calcule clicando nos campos ]

Dollar : = Real :
Aide - Send and Get JSON
Enviar, requisitar e apagar JSON das planilhas do google/ Neste tópico você não só aprenderá, como enviar Json as planilhas do google, mas também, a requisitar dados e apagar dados especificos. [ bons estudos ]
Confira
EMDN74q0wxo
app
manifest
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"    
          package="aksr.com.br.json">
    <uses-permission 
          android:name="android.permission.INTERNET" />
    <application        
          android:allowBackup="true"        
          android:name=".mApplication"        
          android:icon="@drawable/icon"        
          android:label="@string/app_name"        
          android:supportsRtl="true"        
          android:theme="@style/AppTheme">
        <activity 
          android:name=".Send_And_GetARRAYLIST"            
          android:label="@string/atvum">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
java
aksr.com.br.json
adapter
AdapterViewCustom
package aksr.com.br.json.adapter;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
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;
import java.util.ArrayList;
import aksr.com.br.json.R;
import static aksr.com.br.json.Send_And_GetARRAYLIST.adpt;

public class AdapterViewCustom extends BaseAdapter {

    private Activity context_1;
    private String datatodelete;
    private ArrayList<Getters_Setters> pairs;

    public AdapterViewCustom(Activity context, ArrayList<Getters_Setters> pairs) {
        context_1 = context;
        this.pairs = pairs;
    }

    @Override    public int getCount() {
        return pairs.size();
    }

    @Override    public Object getItem(int position) {
        return pairs.get(position);
    }

    @Override    public long getItemId(int position) {
        return position;
    }

    @Override    public View getView(final int position, View convertView, final ViewGroup parent) {
        ViewHolder viewHolder = null;

        if (convertView == null) {
            convertView = LayoutInflater.from(context_1).inflate(R.layout.list_view_custom, null);
            viewHolder = new ViewHolder();
            viewHolder.dados = convertView.findViewById(R.id.dados);
            viewHolder.data =  convertView.findViewById(R.id.data);
            viewHolder.delete =  convertView.findViewById(R.id.delete);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.dados.setText(pairs.get(position).dados);
        viewHolder.data.setText(pairs.get(position).data);

        final ViewHolder finalViewHolder = viewHolder;
        viewHolder.delete.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                datatodelete = finalViewHolder.data.getText().toString();
                RequestQueue queue = Volley.newRequestQueue(context_1);
                String url ="https://script.google.com/macros/s/AKfycbyb1aa0Ryxr4hhQIXqeRn7p4z1X7kho1CnZ0zyMvROxpoy5NgY/exec?Delete="+datatodelete;

                StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
                        new Response.Listener<String>() {
                            @Override                            public void onResponse(String response) {
                            }
                        }, new Response.ErrorListener() {
                    @Override                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(context_1, "That didn't work!", Toast.LENGTH_SHORT).show();
                    }
                });
                queue.add(stringRequest);
                pairs.remove(position);
                adpt.notifyDataSetChanged();
            }
        });
        return convertView;
    }

    public  class ViewHolder {
        TextView dados;
        TextView data;
        Button delete;

    }
}
Getters_Setters
package aksr.com.br.json.adapter;

public class Getters_Setters {

    public String dados;
    public String data;
    public Getters_Setters(String dados, String data) {
        this.dados = dados;
        this.data = data;
    }

}
GetJson
BaseStructure
GettersAndSetters
package aksr.com.br.json.GetJson.BaseStructure;

public class GettersAndSetters {
  private String Dados;
  private String Data;
  private String Spread;
  public String getDados() {
    return Dados;
  }
  public void setDados(String dados) {
    Dados = dados;
  }
  public String getData() {
    return Data;
  }
  public void setData(String data) {
    Data = data;
  }
  public String getSpread() {
    return Spread;
  }
  public void setSpread(String spread) {
    Spread = spread;
  }

}

Populate
package aksr.com.br.json.GetJson.BaseStructure;


import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
public class Populate implements JsonDeserializer<GettersAndSetters> {

  @Override  public GettersAndSetters deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    final GettersAndSetters dummyObject = new GettersAndSetters();
    final JsonObject jsonObject = json.getAsJsonObject();

    if(jsonObject.has("dados")){
      if(!jsonObject.get("dados").toString().equals("null")){
        dummyObject.setDados(jsonObject.get("dados").getAsString());
      }else{
        dummyObject.setDados("null");
      }
    }

    if(jsonObject.has("data")){
      if(!jsonObject.get("data").toString().equals("null")){
        dummyObject.setData(jsonObject.get("data").getAsString());
      }else{
        dummyObject.setData("null");
      }
    }

    return dummyObject;
  }
}

others
OkHttp3Stack
package aksr.com.br.json.GetJson.others;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.toolbox.HttpStack;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;
import org.apache.http.entity.BasicHttpEntity;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.message.BasicStatusLine;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;


public class OkHttp3Stack implements HttpStack {

  public OkHttp3Stack() {
  }

  private static HttpEntity entityFromOkHttpResponse(Response r) throws IOException {
    BasicHttpEntity entity = new BasicHttpEntity();
    ResponseBody body = r.body();

    assert body != null;
    entity.setContent(body.byteStream());
    entity.setContentLength(body.contentLength());
    entity.setContentEncoding(r.header("Content-Encoding"));

    if (body.contentType() != null) {
      //noinspection ConstantConditions      entity.setContentType(body.contentType().type());
    }
    return entity;
  }

  @SuppressWarnings("deprecation")
  private static void setConnectionParametersForRequest(okhttp3.Request.Builder builder,
      Request<?> request)
      throws IOException, AuthFailureError {
    switch (request.getMethod()) {
      case Request.Method.DEPRECATED_GET_OR_POST:
        // Ensure backwards compatibility.  Volley assumes a request with a null body is a GET.        
byte[] postBody = request.getPostBody();
        if (postBody != null) {
          builder.post(RequestBody
              .create(MediaType.parse(request.getPostBodyContentType()), postBody));
        }
        break;
      case Request.Method.GET:
        builder.get();
        break;
      case Request.Method.DELETE:
        builder.delete();
        break;
      case Request.Method.POST:
        //noinspection ConstantConditions        builder.post(createRequestBody(request));
        break;
      case Request.Method.PUT:
        //noinspection ConstantConditions        builder.put(createRequestBody(request));
        break;
      case Request.Method.HEAD:
        builder.head();
        break;
      case Request.Method.OPTIONS:
        builder.method("OPTIONS", null);
        break;
      case Request.Method.TRACE:
        builder.method("TRACE", null);
        break;
      case Request.Method.PATCH:
        //noinspection ConstantConditions        builder.patch(createRequestBody(request));
        break;
      default:
        throw new IllegalStateException("Unknown method type.");
    }
  }

  private static ProtocolVersion parseProtocol(final Protocol p) {
    switch (p) {
      case HTTP_1_0:
        return new ProtocolVersion("HTTP", 1, 0);
      case HTTP_1_1:
        return new ProtocolVersion("HTTP", 1, 1);
      //noinspection deprecation      
case SPDY_3:
        return new ProtocolVersion("SPDY", 3, 1);
      case HTTP_2:
        return new ProtocolVersion("HTTP", 2, 0);
    }

    throw new IllegalAccessError("Unkwown protocol");
  }

  private static RequestBody createRequestBody(Request r) throws AuthFailureError {
    final byte[] body = r.getBody();
    if (body == null) {
      return null;
    }

    return RequestBody.create(MediaType.parse(r.getBodyContentType()), body);
  }

  @Override  public HttpResponse performRequest(Request<?> request,
      Map<String, String> additionalHeaders)
      throws IOException, AuthFailureError {

    OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
    int timeoutMs = request.getTimeoutMs();

    clientBuilder.connectTimeout(10000, TimeUnit.MILLISECONDS);
    clientBuilder.readTimeout(10000, TimeUnit.MILLISECONDS);
    clientBuilder.writeTimeout(10000, TimeUnit.MILLISECONDS);

    okhttp3.Request.Builder okHttpRequestBuilder = new okhttp3.Request.Builder();
    okHttpRequestBuilder.url(request.getUrl());

    Map<String, String> headers = request.getHeaders();
    for (final String name : headers.keySet()) {
      okHttpRequestBuilder.addHeader(name, headers.get(name));
    }
    for (final String name : additionalHeaders.keySet()) {
      okHttpRequestBuilder.addHeader(name, additionalHeaders.get(name));
    }

    setConnectionParametersForRequest(okHttpRequestBuilder, request);

    OkHttpClient client = clientBuilder.build();
    okhttp3.Request okHttpRequest = okHttpRequestBuilder.build();
    Call okHttpCall = client.newCall(okHttpRequest);
    Response okHttpResponse = okHttpCall.execute();

    StatusLine responseStatus = new BasicStatusLine(parseProtocol(okHttpResponse.protocol()),
        okHttpResponse.code(), okHttpResponse.message());
    BasicHttpResponse response = new BasicHttpResponse(responseStatus);
    response.setEntity(entityFromOkHttpResponse(okHttpResponse));

    Headers responseHeaders = okHttpResponse.headers();
    for (int i = 0, len = responseHeaders.size(); i < len; i++) {
      final String name = responseHeaders.name(i), value = responseHeaders.value(i);
      if (name != null) {
        response.addHeader(new BasicHeader(name, value));
      }
    }

    return response;
  }
}

GsonGetRequest
package aksr.com.br.json.GetJson;

import android.support.annotation.NonNull;

import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;

public class GsonGetRequest<T> extends Request<T> {

  private final Gson gson;
  private final Type type;
  private final Response.Listener<T> listener;

  public GsonGetRequest
      (
          @NonNull final String url,
          @NonNull final Type type,
          @NonNull final Gson gson,
          @NonNull final Response.Listener<T> listener,
          @NonNull final Response.ErrorListener errorListener
      ) {
    super(Method.GET, url, errorListener);

    this.gson = gson;
    this.type = type;
    this.listener = listener;
  }

  @Override  protected void deliverResponse(T response) {
    listener.onResponse(response);
  }

  @Override  protected Response<T> parseNetworkResponse(NetworkResponse response) {
    try {
      String json = new String(response.data, HttpHeaderParser.parseCharset(response.headers));

      //noinspection unchecked
      return (Response<T>) Response.success          (
              gson.fromJson(json, type),
              HttpHeaderParser.parseCacheHeaders(response)
          );
    } catch (UnsupportedEncodingException e) {
      return Response.error(new ParseError(e));
    } catch (JsonSyntaxException e) {
      return Response.error(new ParseError(e));
    }
  }
}

Requisicao
package aksr.com.br.json.GetJson;

import android.support.annotation.NonNull;
import android.util.Log;
import com.android.volley.Response;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import aksr.com.br.json.GetJson.BaseStructure.GettersAndSetters;
import aksr.com.br.json.GetJson.BaseStructure.Populate;

public class Requisicao {
  private static final Gson gson = new GsonBuilder()
      .registerTypeAdapter(GettersAndSetters.class, new Populate())
      .create();


                       /*  ARRAYLIST  */    public static GsonGetRequest<ArrayList<GettersAndSetters>> ARRAYLIST
            (@NonNull final Response.Listener<ArrayList<GettersAndSetters>> listener,
             @NonNull final Response.ErrorListener errorListener
            ) {
        final String url ="https://script.google.com/macros/s/AKfycbyh8VjrVJgH4aP0LGbc8hhHdTQ5UI9UOUW2aYTdJ4l6ISqHMKw/exec?dados=ARRAY";
        Log.d("ARRAYLIST",url);
        return new GsonGetRequest<>
                (
                        url,
                        new TypeToken<ArrayList<GettersAndSetters>>() {
                        }.getType(),
                        gson,
                        listener,
                        errorListener
                );
    }


                           /*  OBJECT  */    public static GsonGetRequest<GettersAndSetters> OBJECT
            (@NonNull final Response.Listener<GettersAndSetters> listener,
             @NonNull final Response.ErrorListener errorListener
            ) {
        final String url = "https://script.google.com/macros/s/AKfycbyh8VjrVJgH4aP0LGbc8hhHdTQ5UI9UOUW2aYTdJ4l6ISqHMKw/exec?dados=OBJECT";

        Log.d("OBJECT",url);
        return new GsonGetRequest<>
                (
                        url,
                        new TypeToken<GettersAndSetters>() {
                        }.getType(),
                        gson,
                        listener,
                        errorListener
                );
    }
}

SendJson
Send
package aksr.com.br.json.SendJson;

import android.os.AsyncTask;
import android.util.Log;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Iterator;
import javax.net.ssl.HttpsURLConnection;
import static aksr.com.br.json.Send_And_GetARRAYLIST.DATA;
import static aksr.com.br.json.Send_And_GetARRAYLIST.dadosStr;

public  class Send extends AsyncTask<String, Void, String> {
        protected void onPreExecute() { }
        @Override        protected String doInBackground(String... arg0) {
            try {
                URL url = new URL("https://script.google.com/macros/s/AKfycbyb1aa0Ryxr4hhQIXqeRn7p4z1X7kho1CnZ0zyMvROxpoy5NgY/exec");
                JSONObject postDataParams = new JSONObject();
                postDataParams.put("dados",  dadosStr    );
                postDataParams.put("data", DATA    );
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setReadTimeout(15000);
                conn.setConnectTimeout(15000);
                conn.setRequestMethod("POST");
                conn.setDoInput(true);
                conn.setDoOutput(true);
                OutputStream os = conn.getOutputStream();
                BufferedWriter writer = new BufferedWriter(
                        new OutputStreamWriter(os, "UTF-8"));
                writer.write(getPostDataString(postDataParams));
                writer.flush();
                writer.close();
                os.close();
                int responseCode = conn.getResponseCode();
                if (responseCode == HttpsURLConnection.HTTP_OK) {
                    BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                    StringBuffer sb = new StringBuffer("");
                    String line = "";
                    while ((line = in.readLine()) != null) {
                        sb.append(line);
                        break;
                    }
                    in.close();
                    return sb.toString();
                } else {
                    return "false: " + responseCode;

                }

            } catch (Exception e) {
                return "Exception: " + e.getMessage();
            }
        }

        @Override        protected void onPostExecute(String result) { }

        String getPostDataString(JSONObject params) throws Exception {
            StringBuilder result = new StringBuilder();
            boolean first = true;
            Iterator<String> itr = params.keys();
            while (itr.hasNext()) {
                String key = itr.next();
                Object value = params.get(key);
                if (first)
                    first = false;
                else                result.append("&");
                result.append(URLEncoder.encode(key, "UTF-8"));
                result.append("=");
                result.append(URLEncoder.encode(value.toString(), "UTF-8"));
            }
            return result.toString();

        }
    }

mApplication
package aksr.com.br.json;

import android.app.Application;
import android.content.SharedPreferences;
import android.support.annotation.NonNull;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import aksr.com.br.json.GetJson.others.OkHttp3Stack;

public class mApplication extends Application {
    SharedPreferences Preferences;
    SharedPreferences.Editor Editor;
    private RequestQueue mRequestQueue;
    private static mApplication sInstance;
    public static mApplication getInstance() {
        return sInstance;
    }
    private static void addRequest(@NonNull final Request<?> request) {
        getInstance().getVolleyRequestQueue().add(request);
    }
    public static void addRequest(@NonNull final Request<?> request, @NonNull final String tag) {
        request.setTag(tag);
        addRequest(request);
    }
    public static void cancelAllRequests(@NonNull final String tag) {
        getInstance().getVolleyRequestQueue().cancelAll(tag);
    }
    @Override    public void onCreate() {
        super.onCreate();
        sInstance = this;
        Preferences = getSharedPreferences("ID", MODE_PRIVATE);
        Editor = Preferences.edit();
    }
    @NonNull    public RequestQueue getVolleyRequestQueue() {
        if (mRequestQueue == null) {
            mRequestQueue = Volley.newRequestQueue(this, new OkHttp3Stack());
        }
        return mRequestQueue;
    }
    @Override    public void onLowMemory() {
        super.onLowMemory();
    }
    @Override    public void onTerminate() {
        super.onTerminate();
    }
    
}

Send_And_GetARRAYLIST
package aksr.com.br.json;

import android.app.Activity;
import android.app.ProgressDialog;
import android.support.annotation.NonNull;
import android.os.Bundle;
import android.text.InputFilter;
import android.text.format.Time;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Locale;
import aksr.com.br.json.GetJson.BaseStructure.GettersAndSetters;
import aksr.com.br.json.GetJson.GsonGetRequest;
import aksr.com.br.json.GetJson.Requisicao;
import aksr.com.br.json.SendJson.Send;
import aksr.com.br.json.adapter.AdapterViewCustom;
import aksr.com.br.json.adapter.Getters_Setters;

public class Send_And_GetARRAYLIST extends Activity {
    public  EditText edtSend;
    Button btnSend;
    public static Button loadARRAY;
    ListView lv;
    public static String dadosStr;
    Time t;
    Date date;
    String FORMATO;
    SimpleDateFormat dateFormat;
    public static String DATA;
    ArrayList<Getters_Setters> pairs;
    public static AdapterViewCustom adpt;
    ProgressDialog progressDialog;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        adpt = new AdapterViewCustom(this, pairs);
        progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("Loading");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setCancelable(false);
        t = new Time(Time.getCurrentTimezone());
        t.setToNow();
        lv = findViewById(R.id.lvdata);
        edtSend = findViewById(R.id.edtSend);
        edtSend.setFilters(new InputFilter[]{new InputFilter.LengthFilter(10)});
        btnSend = findViewById(R.id.btnSend);
        btnSend.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                dadosStr = edtSend.getText().toString();
                if (dadosStr.length() > 0) {
                    edtSend.setText("");
                    FORMATO = t.format("%Y/%m/%d");
                    date = new Date(System.currentTimeMillis());
                    dateFormat = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
                    String var = dateFormat.format(date);
                    DATA = var + " - " + FORMATO;
                    new Send().execute();
                }

            }
        });
        loadARRAY = findViewById(R.id.loadARRAY);
        loadARRAY.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                lv.setAdapter(null);
                adpt.notifyDataSetChanged();
                progressDialog.show();
                ARRAYLIST();

            }
        });
    }
    
    public void  ARRAYLIST() {
        final GsonGetRequest<ArrayList<GettersAndSetters>> gsonGetRequest =
                Requisicao.ARRAYLIST(
                    new Response.Listener<ArrayList<GettersAndSetters>>() {
                        @Override                        public void onResponse(ArrayList<GettersAndSetters> dummyObjectArrayList) {
                            onApiResponse(dummyObjectArrayList);
                        }
                    },
                    new Response.ErrorListener() {
                        @Override                        public void onErrorResponse(VolleyError error) {
                            onApiError(error);
                        }
                    }
            );
        mApplication.addRequest(gsonGetRequest, "tagTree");
    }

    private void onApiResponse(@NonNull final ArrayList<GettersAndSetters> dummyObjectArrayList) {
        setData(dummyObjectArrayList);
    }

    private void onApiError(VolleyError error) { }

    private void setData(@NonNull final ArrayList<GettersAndSetters> dummyObjectArrayList) {
        pairs = new ArrayList<>(dummyObjectArrayList.size());
        for (int i = 0; i < dummyObjectArrayList.size(); i++) {
            String dados = dummyObjectArrayList.get(i).getDados();
            String data = dummyObjectArrayList.get(i).getData();

            pairs.add(new Getters_Setters(dados, data));
        }
        adpt = new AdapterViewCustom(this, pairs);
        lv.setAdapter(adpt);
        progressDialog.dismiss();
        
    }
}

res
drawable
button.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" > 
    <corners android:bottomRightRadius="5dp"
 android:bottomLeftRadius="5dp"
 android:topLeftRadius="5dp"
 android:topRightRadius="5dp" /> 
  
    <stroke android:width="1dp" android:color="#a0a0a0" /> 
    
    <padding android:bottom="10dp"
 android:left="10dp"
 android:right="10dp"
 android:top="10dp" /> 
  
    <solid android:color="#f0f0f0" /> 

</shape>

icon.png
IMAGEM
layout
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    
 xmlns:tools="http://schemas.android.com/tools"    
 android:layout_width="match_parent"    
 android:layout_height="match_parent"    
 tools:context=".Send_And_GetARRAYLIST">

    <RelativeLayout        
 android:id="@+id/toolbar"        
 android:layout_width="match_parent"        
 android:layout_height="50dp"        
 android:layout_alignParentTop="true"        
 android:background="@color/colorPrimary">
        
        <TextView            
  android:id="@+id/textView"            
  android:layout_width="match_parent"            
  android:layout_height="wrap_content"            
  android:layout_alignStart="@+id/toolbar"            
  android:layout_centerVertical="true"            
  android:text="@string/atvum"            
  android:textColor="@color/branco"            
  android:textSize="18sp"            
  android:textStyle="bold" />
    </RelativeLayout>

    <RelativeLayout        
 android:id="@+id/body"        
 android:layout_width="wrap_content"        
 android:layout_height="match_parent"        
 android:layout_below="@+id/toolbar"        
 android:background="@color/seekbar">

        <EditText            
  android:id="@+id/edtSend"            
  android:layout_width="wrap_content"            
  android:layout_height="wrap_content"            
  android:layout_alignParentTop="true"            
  android:ems="10"            
  android:hint="Type here text to send"            
  android:inputType="textPersonName" />

        <Button            
  android:id="@+id/btnSend"            
  android:layout_width="wrap_content"            
  android:layout_height="wrap_content"            
  android:layout_alignParentEnd="true"            
  android:layout_alignParentTop="true"            
  android:background="@drawable/button"            
  android:text="Send" />

        <Button            
  android:id="@+id/loadARRAY"            
  android:layout_width="wrap_content"            
  android:layout_height="wrap_content"            
  android:layout_below="@+id/edtSend"            
  android:layout_centerHorizontal="true"            
  android:background="@drawable/button"            
  android:text="Get ARRAY" />

        <ListView            
  android:id="@+id/lvdata"            
  android:layout_width="match_parent"            
  android:layout_height="wrap_content"            
  android:layout_below="@+id/loadARRAY"            
  android:background="@color/cinzaClaro" />
        
    </RelativeLayout>
</RelativeLayout>

list_view_custom.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    
 android:layout_width="match_parent"    
 android:layout_height="wrap_content"    
 android:background="@drawable/button">

    <RelativeLayout        
 android:layout_width="match_parent"        
 android:layout_height="wrap_content"        
 android:background="@color/azulescuro">

        <TextView            
  android:id="@+id/data"            
  android:layout_width="wrap_content"            
  android:layout_height="wrap_content"            
  android:background="@color/amarela"            
  android:text="data" />

        <TextView            
  android:id="@+id/dados"            
  android:layout_width="wrap_content"            
  android:layout_height="wrap_content"            
  android:layout_below="@+id/data"            
  android:background="@drawable/button"            
  android:text="dados" />

        <Button            
  android:id="@+id/delete"            
  android:layout_width="40dp"            
  android:layout_height="40dp"            
  android:layout_alignParentEnd="true"            
  android:layout_alignParentTop="true"            
  android:background="@android:drawable/ic_delete" />
    </RelativeLayout>


</RelativeLayout>

values
colors.xml
<?xml version="1.0" encoding="utf-8"?><resources>
    <color name="colorPrimaryDark">#202020</color>
    <color name="colorPrimary">#0d0d0d</color>
    <color name="colorAccent">#FF4081</color>
    <color name="laranja">#ffa011</color>
    <color name="preto">#000000</color>
    <color name="cinza">#606060</color>
    <color name="branco">#ffffff</color>
    <color name="vermelha">#ff0000</color>
    <color name="amarela">#ffff00</color>
    <color name="verde">#00ff00</color>
    <color name="verdescuro">#003300</color>
    <color name="azul">#00ffff</color>
    <color name="azulescuro">#3F51B5</color>
    <color name="rosa">#ff0099</color>
    <color name="selector_focused_red">#ff0000</color>
    <color name="seekbarfree">#ff0099</color>
    <color name="seekbar">#ffff99</color>
    <color name="cinzaClaro">#cecece</color>
</resources>

strings.xml
<resources>
    <string name="app_name">JSON-SendAndGet</string>
    <string name="atvum">Send_And_GetARRAYLIST</string>
</resources>

styles.xml
<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>

Gradle scripts
build.gradle(Project:JSONSendAndGet)
buildscript {
        repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.+    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
    compileSdkVersion 27    
 useLibrary 'org.apache.http.legacy'    
 defaultConfig {
        applicationId "aksr.com.br.json"        
  minSdkVersion 16        
  targetSdkVersion 27        
  versionCode 1        
  versionName "1.0"        
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    
  }
    buildTypes {
        release {
            minifyEnabled false            
   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'        
   }
    }
}

dependencies {
 compile fileTree(dir: 'libs', include: ['*.jar'])
 compile 'com.android.support:appcompat-v7:27.1.1'    
 compile 'com.android.support.constraint:constraint-layout:1.1.1'    
 compile 'com.mcxiaoke.volley:library:1.0.19'    
 compile 'com.google.code.gson:gson:2.8.4'    
 compile 'com.squareup.okhttp3:okhttp:3.9.1'    
 testCompile 'junit:junit:4.12'    
 androidTestCompile 'com.android.support.test:runner:1.0.2'    
 androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.2'
}

proguard-rules.pro(ProGuard Rules for app)
-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8
-keep class android.content.pm.PackageInstaller.**
-dontwarn com.squareup.okhttp.**

Send.gs
function doGet(e){
handleFunction(e);
}
function doPost(e){
handleFunction(e);
}

function handleFunction(request){ 
 var Delete = request.parameter.Delete; 
  if(Delete!=null){
    var ss = SpreadsheetApp.openById("12nILLdBfF9h_mLwTA2jWy5hrE2xcDkkIvct8xDbuP7M");
    var sheet = ss.getActiveSheet();
    var rows = sheet.getDataRange();
    var numRows = rows.getNumRows();
    var values = rows.getValues();
  Logger.log(Delete)
  var rowsDeleted = 0;
  for (var i = 0; i <= numRows - 1; i++) {
    var row = values[i];
    if (row[1] == Delete || row[1] == '') { 
      sheet.deleteRow((parseInt(i)+1) - rowsDeleted);
      rowsDeleted++;
    }
  }

  }else{
  var dados = request.parameter.dados;
  var data = request.parameter.data;
//https://docs.google.com/spreadsheets/d/12nILLdBfF9h_mLwTA2jWy5hrE2xcDkkIvct8xDbuP7M/edit#gid=0  
var ss = SpreadsheetApp.openById("12nILLdBfF9h_mLwTA2jWy5hrE2xcDkkIvct8xDbuP7M");
  var first = ss.getSheetByName("dados");

  var rowContent = ss.appendRow([dados,data]);
  }
 
}

Requisicao.gs
function doGet(e) {
    var json = convertSheet2JsonText();
    var dados = e.parameter.dados;
  if(dados =="OBJECT"){ var stringified = JSON.stringify({spread: json});}
  if(dados =="ARRAY"){  var stringified = JSON.stringify(json); } 
    return ContentService.createTextOutput(stringified)
    .setMimeType(ContentService.MimeType.JSON);
  
}
function convertSheet2JsonText() {
 //https://docs.google.com/spreadsheets/d/12nILLdBfF9h_mLwTA2jWy5hrE2xcDkkIvct8xDbuP7M/edit#gid=0  
var sheet = SpreadsheetApp.openById("12nILLdBfF9h_mLwTA2jWy5hrE2xcDkkIvct8xDbuP7M").getActiveSheet();
  var colStartIndex = 1;
  var rowNum = 1;
  var firstRange = sheet.getRange(1, 1, 1, sheet.getLastColumn());
  var firstRowValues = firstRange.getValues();
  var titleColumns = firstRowValues[0];
  
  var lastRow = sheet.getLastRow();
  var rowValues = [];
  for(var rowIndex=2; rowIndex<=lastRow; rowIndex++) {
    var colStartIndex = 1;
    var rowNum = 1;
    var range = sheet.getRange(rowIndex, colStartIndex, rowNum, sheet.getLastColumn());
    var values = range.getValues();
  
    rowValues.push(values[0]);
  }
 
  var jsonArray = [];
  for(var i=0; i<rowValues.length; i++) {
    var line = rowValues[i];
    var json = new Object();
    for(var j=0; j<titleColumns.length; j++) {
      json[titleColumns[j]] = line[j];
    }
    jsonArray.push(json);
  }
  return jsonArray ;
}