Java 我如何调用意图并将其放入向量中?
s将是我的意图,我将如何将其放入我的SendVEctor中Java 我如何调用意图并将其放入向量中?,java,android,string,vector,Java,Android,String,Vector,s将是我的意图,我将如何将其放入我的SendVEctor中 谢谢。我不知道目的是什么。但是你可以这样做 b = this.getIntent().getExtras(); s = this.getIntent().getStringExtra("DEFAULTTEXT"); public void onClick(View v) { String a = "http://152.226.152.156:1010/jsp-ex
谢谢。我不知道目的是什么。但是你可以这样做
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();
我不知道目的是什么。但是你可以这样做
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
不是您的意图,s
是您实际意图的DEFAULTTEXT
属性的值。从这个问题上,很难说出你想要实现什么
实际代码将此值添加到向量中。因为您添加到向量的所有内容都是字符串,所以我假设向量的声明和构造如下:
SendVEctor sVector = new SendVEctor();
sVector.add(this.getIntent())
Vector<String> SendVEctor = new Vector<String>();
然后,您将能够使用表达式添加意图
Vector SendVEctor = new Vector();
但是:意图
不可序列化,因此无法将向量写入对象输出流
请添加更多详细信息,并解释您真正想要序列化的内容。仅文本或文本与对象混合。
s
不是您的意图,s
是您实际意图的DEFAULTTEXT
属性的值。从这个问题上,很难说出你想要实现什么
实际代码将此值添加到向量中。因为您添加到向量的所有内容都是字符串,所以我假设向量的声明和构造如下:
SendVEctor sVector = new SendVEctor();
sVector.add(this.getIntent())
Vector<String> SendVEctor = new Vector<String>();
然后,您将能够使用表达式添加意图
Vector SendVEctor = new Vector();
但是:意图
不可序列化,因此无法将向量写入对象输出流
请添加更多详细信息,并解释您真正想要序列化的内容。只有文本或文本与对象混合。我在哪里声明?在我的onclick方法下?是SendVEctor是一种向量。s将是我从另一个类文件中获取的字符串。我将在哪里声明它?在我的onclick方法下?是SendVEctor是一种向量。s将是我从另一个类文件中获取的字符串。