host unresolved error!!

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

host unresolved error!!

Postby beta2 » Mon Dec 14, 2009 9:59 am

Hi iam using sdk 1.6,my browser works fine nd iam able to connect to all sites fromit.Iam behind proxy.
Iam not able to connect to gmail through my code,when i do it,i get host unresolved error.
I surfed regarding this error and found it to be something common,but none of the sites and blogs gave a solution to this problem.
I have given internet permissions in manifest file too.
The application basically tries to login to gmail with proper authentication and is supposed to fetch google contacts to emulator.
But iam not able to proceed further as i get this error please help me out!!
Any valuable suggestion welcome.
Thanks in advance
Code: Select all

# package com.example.socapp; 
#   
# import android.app.Activity; 
# import android.os.Bundle; 
#   
# /*public class socapp extends Activity {
#     
#     @Override
#     public void onCreate(Bundle savedInstanceState) {
#         super.onCreate(savedInstanceState);
#         setContentView(R.layout.main);
#     }
# }*/ 
#   
# import android.app.Activity; 
# import android.app.ProgressDialog; 
# import android.os.Bundle; 
# import android.os.Handler; 
# import android.os.Message; 
# import android.util.Log; 
# import android.view.View; 
# import android.view.View.OnClickListener; 
# import android.widget.Button; 
# import android.widget.EditText; 
# import android.widget.TextView; 
#   
# import com.example.socapp.HTTPRequestHelper; 
#   
# import org.apache.http.client.ResponseHandler; 
#   
# import java.io.UnsupportedEncodingException; 
# import java.net.URLEncoder; 
# import java.util.HashMap; 
#   
# /**
#  * Android Apache HTTP example demonstrating using the ClientLogin feature of the Google Data APIs
#  * (obtain a token, and send it as a header with subsequent requests).
#  * 
#  * @author charliecollins
#  * 
#  */ 
# public class socapp extends Activity { 
#   
#     private static final String CLASSTAG = socapp.class.getSimpleName(); 
#     private static final String URL_GET_GTOKEN = "https://www.google.com/accounts/ClientLogin"; 
#     private static final String URL_GET_CONTACTS_PREFIX = "http://www.google.com/m8/feeds/contacts/"; // liz%40gmail.com 
#     private static final String URL_GET_CONTACTS_SUFFIX = "/full"; 
#     private static final String GTOKEN_AUTH_HEADER_NAME = "Authorization"; 
#     private static final String GTOKEN_AUTH_HEADER_VALUE_PREFIX = "GoogleLogin auth="; 
#     private static final String PARAM_ACCOUNT_TYPE = "accountType"; 
#     private static final String PARAM_ACCOUNT_TYPE_VALUE = "HOSTED_OR_GOOGLE"; 
#     private static final String PARAM_EMAIL = "Email"; 
#     private static final String PARAM_PASSWD = "Passwd"; 
#     private static final String PARAM_SERVICE = "service"; 
#     private static final String PARAM_SERVICE_VALUE = "cp"; // google contacts 
#     private static final String PARAM_SOURCE = "source"; 
#     private static final String PARAM_SOURCE_VALUE = "manning-unlockingAndrid-1.0"; 
#   
#     private String tokenValue; 
#   
#     private EditText emailAddress; 
#     private EditText password; 
#     private Button getContacts; 
#     private Button getToken; 
#     private Button clearToken; 
#     private TextView tokenText; 
#     private TextView output; 
#   
#     private ProgressDialog progressDialog; 
#   
#     private final Handler tokenHandler = new Handler() { 
#   
#         @Override 
#         public void handleMessage(final Message msg) { 
#             progressDialog.dismiss(); 
#             String bundleResult = msg.getData().getString("RESPONSE"); 
#             Log.d(Constants.LOGTAG, " " + socapp.CLASSTAG + " response body before auth trim - " 
#                 + bundleResult); 
#   
#             String authToken = bundleResult; 
#             authToken = authToken.substring(authToken.indexOf("Auth=") + 5, authToken.length()).trim(); 
#   
#             tokenValue = authToken; 
#             tokenText.setText(authToken); 
#         } 
#     }; 
#   
#     private final Handler contactsHandler = new Handler() { 
#   
#         @Override 
#         public void handleMessage(final Message msg) { 
#             progressDialog.dismiss(); 
#             String bundleResult = msg.getData().getString("RESPONSE"); 
#             output.setText(bundleResult); 
#         } 
#     }; 
#   
#     @Override 
#     public void onCreate(final Bundle icicle) { 
#         super.onCreate(icicle); 
#         this.setContentView(R.layout.main); 
#   
#         this.emailAddress = (EditText) findViewById(R.id.gclient_email); 
#         this.password = (EditText) findViewById(R.id.gclient_password); 
#   
#         this.getToken = (Button) findViewById(R.id.gclientgettoken_button); 
#         this.clearToken = (Button) findViewById(R.id.gclientcleartoken_button); 
#         this.getContacts = (Button) findViewById(R.id.gclientgetcontacts_button); 
#         this.tokenText = (TextView) findViewById(R.id.gclient_token); 
#         this.output = (TextView) findViewById(R.id.gclient_output); 
#   
#         this.getToken.setOnClickListener(new OnClickListener() { 
#   
#             public void onClick(final View v) { 
#                 output.setText(""); 
#   
#                 if ((tokenValue == null) || tokenValue.equals("")) { 
#                     Log.d(Constants.LOGTAG, " " + socapp.CLASSTAG + " token NOT set, getting it"); 
#                     getToken(emailAddress.getText().toString(), password.getText().toString()); 
#                 } else { 
#                     Log.d(Constants.LOGTAG, " " + socapp.CLASSTAG 
#                         + " token already set, not re-getting it (clear it first)"); 
#                 } 
#             } 
#         }); 
#   
#         this.clearToken.setOnClickListener(new OnClickListener() { 
#   
#             public void onClick(final View v) { 
#                 output.setText(""); 
#                 tokenText.setText(""); 
#                 tokenValue = null; 
#             } 
#         }); 
#   
#         this.getContacts.setOnClickListener(new OnClickListener() { 
#   
#             public void onClick(final View v) { 
#                 output.setText(""); 
#                 getContacts(emailAddress.getText().toString(), tokenValue); 
#             } 
#         }); 
#     }; 
#   
#     @Override 
#     public void onPause() { 
#         super.onPause(); 
#         if ((this.progressDialog != null) && this.progressDialog.isShowing()) { 
#             this.progressDialog.dismiss(); 
#         } 
#     } 
#   
#     private void getContacts(final String email, final String token) { 
#         final ResponseHandler<String> responseHandler = HTTPRequestHelper 
#             .getResponseHandlerInstance(this.contactsHandler); 
#   
#         this.progressDialog = ProgressDialog.show(this, "working . . .", "getting Google Contacts"); 
#   
#         // do the HTTP dance in a separate thread (the responseHandler will fire when complete) 
#         new Thread() { 
#   
#             @Override 
#             public void run() { 
#                 HashMap<String, String> headers = new HashMap<String, String>(); 
#                 headers.put(socapp.GTOKEN_AUTH_HEADER_NAME, 
#                     socapp.GTOKEN_AUTH_HEADER_VALUE_PREFIX + token); 
#   
#                 String encEmail = email; 
#                 try { 
#                     encEmail = URLEncoder.encode(encEmail, "UTF-8"); 
#                 } catch (UnsupportedEncodingException e) { 
#                     Log.e(Constants.LOGTAG, " " + socapp.CLASSTAG, e); 
#                 } 
#                 String url = socapp.URL_GET_CONTACTS_PREFIX + encEmail 
#                     + socapp.URL_GET_CONTACTS_SUFFIX; 
#                 Log.d(Constants.LOGTAG, " " + socapp.CLASSTAG + " getContacts URL - " + url); 
#   
#                 HTTPRequestHelper helper = new HTTPRequestHelper(responseHandler); 
#                 helper.performGet(url, null, null, headers); 
#             } 
#         }.start(); 
#     } 
#   
#     private void getToken(final String email, final String pass) { 
#         final ResponseHandler<String> responseHandler = HTTPRequestHelper.getResponseHandlerInstance(this.tokenHandler); 
#   
#         this.progressDialog = ProgressDialog.show(this, "working . . .", "getting Google ClientLogin token"); 
#   
#         // do the HTTP dance in a separate thread (the responseHandler will fire when complete) 
#         new Thread() { 
#   
#             @Override 
#             public void run() { 
#                 HashMap<String, String> params = new HashMap<String, String>(); 
#                 params.put(socapp.PARAM_ACCOUNT_TYPE, socapp.PARAM_ACCOUNT_TYPE_VALUE); 
#                 params.put(socapp.PARAM_EMAIL, email); 
#                 params.put(socapp.PARAM_PASSWD, pass); 
#                 params.put(socapp.PARAM_SERVICE, socapp.PARAM_SERVICE_VALUE); 
#                 params.put(socapp.PARAM_SOURCE, socapp.PARAM_SOURCE_VALUE); 
#   
#                 HTTPRequestHelper helper = new HTTPRequestHelper(responseHandler); 
#                 helper.performPost(HTTPRequestHelper.MIME_FORM_ENCODED, socapp.URL_GET_GTOKEN, null, null, 
#                     null, params); 
#             } 
#         }.start(); 
#     } 
# } 
beta2
Freshman
Freshman
 
Posts: 2
Joined: Mon Nov 30, 2009 1:09 pm

Top

plzzzzz help

Postby beta2 » Mon Dec 14, 2009 10:00 am

hi ppl,please help me solve the unresolved host problem!! :(
beta2
Freshman
Freshman
 
Posts: 2
Joined: Mon Nov 30, 2009 1:09 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests