Executing URL with parameters using AsyncTask

Viewed 15

I've got little problem with implementing asynctask for my class project.

"PART_OF_URL?title="+tytul+"&author="+autor+"&date="+dataSt+"&username="+imieSt

so this is whole string that should be executed, it works "perfectly" fine like this:

Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("PART_OF_URL?title="+tytul+"&author="+autor+"&date="+dataSt+"&username="+imieSt));
            startActivity(i);

Which sends data to PART_OF_URL website that display order list but instead of that it should be done in asynctask.

Here is whole activity code that handle sending data:

public class Zamowienie extends AppCompatActivity {

TextView tytulzamowieniaTV;
EditText data;
EditText imie;
Button zamawiaj;
Button anuluj;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_zamowienie);
    tytulzamowieniaTV=findViewById(R.id.tytulZamwowienia);
    data=findViewById(R.id.data);
    imie=findViewById(R.id.imie);
    zamawiaj=findViewById(R.id.zamawiaj);
    anuluj=findViewById(R.id.anuluj);
    tytulzamowieniaTV.setText(getIntent().getStringExtra("Tytul"));
    String tytul=getIntent().getStringExtra("Tytul");
    String autor=getIntent().getStringExtra("Autor");
    wyslijZamowienie(tytul,autor);
}

public void wyslijZamowienie(String tytul,String autor){
    zamawiaj.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String dataSt=data.getText().toString();
            String imieSt=imie.getText().toString();
            Intent i = new Intent(Intent.ACTION_VIEW);
            i.setData(Uri.parse("PART_OF_URL?title="+tytul+"&author="+autor+"&date="+dataSt+"&username="+imieSt));
            startActivity(i);

            }

    });

}

}

Understanding asynctask is problematic for me so any help is appreciated.

0 Answers
Related