请你帮我解决android库的使用问题。
http帖子的代码(需要用作库)是:
username =(EditText)findViewById(R.id.editTextusername); password =(EditText)findViewById(R.id.editTextpassword);
submit = (Button)findViewById(R.id.submit);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(username.getText().length()>0 && password.getText().length()>0)
{
URLconnector ss = new URLconnector();
ss.execute("http//ipchicken.com");
}
}
});
}
private class URLconnector extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
String response = "";
for (String url : urls) {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
try {
List<NameValuePair> postParameters = new ArrayList<NameValuePair>();
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(
postParameters);
httppost.setEntity(formEntity);
HttpResponse response1 = httpclient.execute(httppost);
BufferedReader in = new BufferedReader(
new InputStreamReader(response1.getEntity()
.getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String result = sb.toString();
response = result;
System.err.println("My Response :: " + result);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return response;
}
protected void onPostExecute(String result) {
if(result != null)
{
Intent tokenIntent = new Intent(mContext, tokenActivity.class);
Bundle bundle = new Bundle();
bundle.putString("responsedata",result);
tokenIntent.putExtras(bundle);
startActivity(tokenIntent);
}