sách gpt4 ăn đã đi

java - 无效使用 SingleClientConnManager : connection still allocated

In lại 作者:搜寻专家 更新时间:2023-11-01 08:52:32 26 4
mua khóa gpt4 giày nike

我想知道为什么这段代码不执行?我正在尝试通过 POST 方法从我的设备发送数据,但没有错误。该应用程序通过传达“我的应用程序已停止。”在我的设备上自行完成:

这里是执行:

KlientNameValue kn = new KlientNameValue(getApplicationContext());
kn.new MyAsyncTask().execute(zam.klient.getNazwa(),zam.klient.getNip(),zam.klient.getAdres());

这里是代码:

public class KlientNameValue {

List KlientNameValuePairs = new ArrayList();
Context context;
public KlientNameValue(Context context) {
siêu();
this.context=context;
}



public class MyAsyncTask extends AsyncTask {

@Override protected Void doInBackground(String... params) {
// TODO Phương thức tự động tạo stub
postData(params[0], params[1], params[2]);
trả về giá trị null;

}

@Ghi đè
protected void onPostExecute(Void result) {

Toast.makeText(context , "Zlecenie zostało wysłane",
Toast.LENGTH_LONG).show();
}

void postData(String nazwa, String nip, String adres) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("here is my default link :)");

try { // Add your data

KlientNameValuePairs = new ArrayList();
KlientNameValuePairs.add(new BasicNameValuePair("Kli_imie", nazwa));
KlientNameValuePairs.add(new BasicNameValuePair("Kli_adres", adres));
KlientNameValuePairs.add(new BasicNameValuePair( "Kli_nr_telefonu",
nip));



httppost.setEntity(new UrlEncodedFormEntity( KlientNameValuePairs));
HttpResponse response = httpclient.execute(httppost);
//httppost.setEntity(new UrlEncodedFormEntity(
// ZamowienieNameValuePairs)); // HttpResponse response1 =



} catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace(); }

}

}

sai lầm:

02-15 17:45:24.695: E/AndroidRuntime(21890): at android.widget.Toast.(Toast.java:94) 
02-15 17:47:19.343: W/SingleClientConnManager(22288): Invalid use of SingleClientConnManager: connection still allocated.
02-15 17:47:19.343: W/SingleClientConnManager(22288): Make sure to release the connection before allocating another one.

câu trả lời hay nhất

Invalid use of SingleClientConnManager: connection still allocated.

你在消费它之前执行了两次完全错误的http请求。所以删除第二个 httpclient.execute(httppost); 因为你已经执行了这个 http 请求。

然后调用它

httpResponse.getEntity().consumeContent();

Above method is called to indicate that the content of this entity is no longer required. All entity implementations are expected to release all allocated resources as a result of this method invocation

关于java - 无效使用 SingleClientConnManager : connection still allocated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21800495/

26 4 0
Đề xuất bài viết: MySQL Pad 空月汇总报告。 (那里的 3/4 路)
Đề xuất bài viết: c# - 设计游戏对象
Đề xuất bài viết: C#:如何将 long 转换为 ulong
Đề xuất bài viết: android - FFMpeg 移动端视频编码卡顿
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress