/** @see android.app.Activity#onCreate(android.os.Bundle) */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    SharedPreferences myPreferences =
        getApplicationContext().getSharedPreferences("PREFERENCE", MODE_PRIVATE);

    boolean firstrun = myPreferences.getBoolean("firstrun", true);
    if (firstrun) {
      new AlertDialog.Builder(this)
          .setTitle("Warning")
          .setMessage(
              "This app and its developer(s) are not affliated or endorsed by "
                  + "the Port Authority of New York and New Jersey.\n\nThis application obtains your current location "
                  + "and can use it to obtain your three closest stations, then directions to the station you select. To The PATH And Back does not "
                  + "use your location for any other purpose. In addition, neither the location obtained by your device or location "
                  + "you manually entered are stored anywhere by this application.\n\nThe directions provided by this application is obtained from "
                  + "OpenStreetMap via Open MapQuest. The developer(s) of this app, MapQuest and OpenStreetMap, "
                  + "cannot guarentee that the directions given to you are 100% accurate. Use them at your own risk.\n\nFinally, "
                  + "please be aware that the developer(s) cannot guarantee that the station and/or entrance that you want "
                  + "directions for will be open or accurately placed. Again, use the directions and locations provided by this app at your own risk.\n\nAds "
                  + "provided by Google's AdMob/AdSense will be displayed under the tabs in the action bar as well "
                  + "as in the bottom of the screen where you'll select the station you want directions to.")
          .setNeutralButton("OK", null)
          .show();

      myPreferences.edit().putBoolean("firstrun", false).commit();
      myPreferences.edit().putBoolean("imperialUnits", true).commit();
    }

    unitMeasurement = myPreferences.getString("unitMeasurement", "");
    if (unitMeasurement.isEmpty()) {
      myPreferences
          .edit()
          .putString("unitMeasurement", "m")
          .commit(); // Imperial units is the default unit of measurement
      unitMeasurement = myPreferences.getString("unitMeasurement", "");
    }

    AppRater.app_launched(this);

    pathStations = new DatabaseHandler(this);
    getAllStopsAndTrips();
    getAppKey();
    addTabs();

    adView = (AdView) this.findViewById(R.id.adViewMain);
    AdRequest adRequest =
        new AdRequest.Builder().addTestDevice("949F5429A9EC251C1DD4395558D33531").build();
    // AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);
  }