views:

53

answers:

2
    b = this.getIntent().getExtras();
    s = this.getIntent().getStringExtra("DEFAULTTEXT");    

public void onClick(View v) 
        {


            String a = "http://152.226.152.156:1010/jsp-examples/test1";
             URL url = null;
                HttpURLConnection httpurlconnection = null;
                try {
                 url = new URL(a);
                 httpurlconnection = (HttpURLConnection) url
                   .openConnection();
                 httpurlconnection.setDoOutput(true);
                 httpurlconnection.setRequestMethod("POST");


                 Toast.makeText(Booking.this, a, Toast.LENGTH_SHORT).show();
                 Toast.makeText(Booking.this, "Toast1", Toast.LENGTH_SHORT).show();
                 ObjectOutputStream dos = new ObjectOutputStream(httpurlconnection.getOutputStream());
                 SendVEctor.add(txtArrivalTime.getText().toString());
                 SendVEctor.add(txtFerry.getText().toString());
                 SendVEctor.add(txtStatus.getText().toString());
                 SendVEctor.add(txtDestination.getText().toString());
                 SendVEctor.add(s.toString());

                    dos.writeObject(SendVEctor);

                     dos.close();

s would be my intent and how would i put it into my SendVEctor?

Thank you.

+1  A: 

I do not know what Intent is. But you can do something like this,

Vector<Intent> sendVector = new Vector<Intent>();
sendVector.add(this.getIntent());

I assume SendVEctor is a type of Vector, so it would be perfectly legal to add objects to it. It would be better if you can throw some more light on the question.

SendVEctor sVector = new SendVEctor();
sVector.add(this.getIntent())
Bragboy
Where would i declare this? Under my onclick method?
User358218
@User : Can u add some more information to your question
Bragboy
Yes SendVEctor is a type of vector. s would be a string that i took from another class file.
User358218
A: 

s is not your intent, s is the value of the DEFAULTTEXT attribute of your actual intent. From the question, it's really hard to tell what you want to achieve.

The actual code adds this value to the vector. Because all things you add to the vector are String, I assume the vector is declared and constructed like this:

 Vector<String> SendVEctor = new Vector<String>();

In this case you won't be able to add the intent object to the vector, because this vector can hold nothing but Strings.

If the vector is untyped, in other words, declared and constructed like this:

 Vector SendVEctor = new Vector();

then you'll be able to add the intent with the expression

SendVEctor.add(this.getIntent());

but: Intent is not serializable so you won't be able to write the vector to the ObjectOutputStream.

Please add some more details and explain what you really want to serialize. Just text or text mixed with objects.

Andreas_D