/** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (APP_ID == null) {
      Util.showAlert(
          this,
          "Warning",
          "Facebook Applicaton ID must be "
              + "specified before running this example: see Example.java");
    }

    setContentView(R.layout.main);
    mLoginButton = (LoginButton) findViewById(R.id.login);
    mText = (TextView) FacebookApplicationActivity.this.findViewById(R.id.txt);
    mUserPic = (ImageView) FacebookApplicationActivity.this.findViewById(R.id.user_pic);
    //       	mFacebook = new Facebook(APP_ID);
    Utility.mFacebook = new Facebook(APP_ID);
    // Instantiate the asynrunner object for asynchronous api calls.
    Utility.mAsyncRunner = new AsyncFacebookRunner(Utility.mFacebook);
    SessionStore.restore(mFacebook, this);
    SessionEvents.addAuthListener(new FbAPIsAuthListener());
    SessionEvents.addLogoutListener(new FbAPIsLogoutListener());
    mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions);

    if (Utility.mFacebook.isSessionValid()) {
      requestUserData();
    }

    list = (ListView) findViewById(R.id.main_list);

    list.setOnItemClickListener(this);
    list.setAdapter(new ArrayAdapter<String>(this, R.layout.main_list_item, main_items));
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    if (Utility.APP_ID == null) {
      Util.showAlert(
          this,
          "Warning",
          "Facebook Applicaton ID must be "
              + "specified before running this example: see Example.java");
    }

    setContentView(R.layout.main);

    /* Get Handles for all the controls on the screen which needs
     * manipulation
     */
    mLoginButton = (LoginButton) findViewById(R.id.login);
    btnSearchHotel = (Button) findViewById(R.id.btnSearch);
    lblWelcome = (TextView) findViewById(R.id.lblWelcome);
    txtCityName = (EditText) findViewById(R.id.txtCityName);
    layoutForm = (LinearLayout) findViewById(R.id.layoutForm);
    layoutForm.setVisibility(View.INVISIBLE);

    // Create an instance of Facebook object, passing the APP ID.
    Utility.mFacebook = new Facebook(Utility.APP_ID);

    Utility.mAsyncRunner = new AsyncFacebookRunner(Utility.mFacebook);

    SessionStore.restore(Utility.mFacebook, this);
    SessionEvents.addAuthListener(new SampleAuthListener());
    SessionEvents.addLogoutListener(new SampleLogoutListener());
    mLoginButton.init(this, Utility.mFacebook);

    Spinner spin = (Spinner) findViewById(R.id.ddlHotelChain);
    spin.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
            // Set the Hotel Chain selected.
            strHotelChain = items_hotel_chain[position];
          }

          public void onNothingSelected(AdapterView<?> arg0) {
            // So, nothing comes here. ;)
          }
        });

    @SuppressWarnings({"rawtypes", "unchecked"})
    ArrayAdapter aa =
        new ArrayAdapter(this, android.R.layout.simple_spinner_item, items_hotel_chain);

    aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spin.setAdapter(aa);

    btnSearchHotel.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // If city name is entered, call new intent by passing,
            // city name and hotel chain to the new intent.
            if (!txtCityName.getText().toString().trim().equals("")) {
              Intent i = new Intent(getBaseContext(), HotelList.class);
              i.putExtra("cityName", txtCityName.getText().toString().replace(" ", "+").trim());
              i.putExtra("hotelChain", strHotelChain);
              startActivity(i);
            }
            // City name cannot be empty, so tell the user.
            else {
              Toast.makeText(getBaseContext(), "Please enter city name", Toast.LENGTH_SHORT).show();
            }
          }
        });

    if (Utility.mFacebook.isSessionValid()) {
      lblWelcome.setText("Welcome, " + Utility.strUsername);
      layoutForm.setVisibility(View.VISIBLE);
    }
  }