警告/错误的含义 - GbaRequest - GbaRequest:构造方法中调用222的userAgent Apache的HttpClient的/ UNAVAILABLE [英] Warning/Error meaning - GbaRequest - GbaRequest: Constructor Called 222 userAgent Apache-HttpClient/UNAVAILABLE
问题描述
W/System.err(27207): [DEBUG] GbaRequest - GbaRequest: Constructor Called 222 userAgent Apache-HttpClient/UNAVAILABLE (java 1.4)
感谢您事先的协助。我无法找到有关这个错误我在我的项目获得了一个职位。
Thank you in advance for the assistance. I wasn't able to find a post regarding this error I received on my project.
我收到此错误只是有时,虽然我不知道为什么它出现时,会发生,因为它似乎是随机的。我没有注意到我的数据输入任何不寻常的。
I receive this error only sometimes, though I'm not sure why it comes up as it seems random when it occurs. I don't notice anything out of the ordinary in my data input.
我的Android应用程序正在试图使到远程服务器的连接,将数据推入PostgreSQL的表。会有人能够引用我到适当的文件这个错误或解释其含义。我AP preciate的援助。
My android application is attempting to make a connection to a remote server and push data into the PostgreSQL tables. Would anyone be able to refer me to the proper documentation for this error or explain its meaning. I appreciate the assistance.
下面是我的code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreProtocolPNames;
import org.json.JSONException;
import org.json.JSONObject;
import android.util.Log;
public class JSONParser
{
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
public JSONParser()
{
// Empty Constructor
}
public JSONObject getJSONFromUrl(String url)
{
try
{
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, System.getProperty("http.agent"));
HttpPost httpPost = new HttpPost(url);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
catch(UnsupportedEncodingException e)
{
e.printStackTrace();
}
catch(ClientProtocolException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
json = sb.toString();
}
catch (Exception e)
{
Log.e("Buffer Error", "Error converting result " + e.toString());
}
try
{
jObj = new JSONObject(json);
}
catch (JSONException e)
{
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
public JSONObject makeHttpRequest(String url, String method, List<NameValuePair> params)
{
try
{
if (method == "POST")
{
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, System.getProperty("http.agent"));
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
else if (method == "GET")
{
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, System.getProperty("http.agent"));
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
catch (ClientProtocolException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
json = sb.toString();
}
catch (Exception e)
{
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try
{
jObj = new JSONObject(json);
}
catch (JSONException e)
{
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
return jObj;
}
}
推荐答案
这是不是一个错误本身的 Apache的HttpClient的/不可用(Java 1.4中)的是Apache的默认用户代理字符串的HttpClient
That is not an error itself, Apache-HttpClient/UNAVAILABLE (java 1.4) is the default User Agent string for your Apache HttpClient.
这发生在你不发送用户代理(用户代理)通过HTTP头,那么手机GBA服务警告你。
This happens when you don't send the User Agent ("User-Agent:") via HTTP headers, then the phone GBA Service warn you about that.
如果您想发送系统默认的用户代理,你可以做
If you want send the default system User Agent you can do
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, System.getProperty("http.agent"));
这应该是像
Dalvik/1.6.0 (Linux; U; Android 4.2.2; Galaxy Nexus Build/JDQ39)
如果您要发送自定义用户代理,你可以做
or if you want sent a custom User Agent you can do
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "My user agent");
,也可以通过设置页眉的setHeader
法
requestOrPost.setHeader("User-Agent", USER_AGENT);
这篇关于警告/错误的含义 - GbaRequest - GbaRequest:构造方法中调用222的userAgent Apache的HttpClient的/ UNAVAILABLE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!