I have problems with android study when entering variables and other

0

hello friends, how could you tell me why you mark error in these lines of code my android studio, the lines of code that appear in bold or with double asterisk are my mistakes, someone to help me please is urgent

package com.example.danhermes.reportestransportepublico;

import android.app.Activity;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

public class reportes extends AppCompatActivity {

EditText nombre, reporte;
Button agregar;
**HttpClient** cliente;
**HttpPost** post;
List<**NameValuePair**> lista;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.reportes);

    nombre = (EditText)(super.findViewById(R.id.etnombre));
    reporte = (EditText)(super.findViewById(R.id.etreporte));

    agregar = (Button)(super.findViewById(R.id.btnagregar));

    agregar.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if(nombre.getText().toString().equals("")){
                Toast.makeText(reportes.this, "Ingresa Un Nombre", Toast.LENGTH_SHORT).show();
            }
            else if(reporte.getText().toString().equals("")){
                    Toast.makeText(reportes.this, "Ingresa Un Reporte", Toast.LENGTH_SHORT).show();
            }
            else
                new EnviarDatos(reportes.this).execute();
        }
    });
}
class EnviarDatos extends AsyncTask<String, String, String>{
    private Activity contexto;
    EnviarDatos(Activity context){
        this.contexto = context;
    }

    @Override
    protected String doInBackground(String... strings) {
        if(datos()){

        }


        return null;
    }
}

private boolean datos()
{
    cliente = new **DefaultHttpClient()**;
    post = new **HttpPost**("http://192.168.1.254/dbandroid/ws/InsertarUsuario.php");
    lista = new ArrayList<**NameValuePair**>(2);
    lista.**add**(new **BasicNameValuePair**("nombre", nombre.getText().toString().trim()));
    lista.**add**(new **BasicNameValuePair**("reporte", reporte.getText().toString().trim()));

    try{
        post.**setEntity**(new **UrlEncodedFormEntity**(lista));
        cliente.**execute**(post);
        return true;
    }
    catch (UnsupportedEncodingException e)
    {
        e.printStackTrace();
    }
    catch(**ClientProtocolException** e)
    {
        e.**printStackTrace()**;
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }
    return false;
}


  }
    
asked by Dan Hermes Reyes Osnaya 31.03.2018 в 20:15
source

1 answer

0

It seems to me that you are not importing DefaultHttpClient, if you have problems importing the library this Link can help you. Greetings

    
answered by 02.04.2018 / 01:44
source