package com.example.android.sunshine;

import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends ActionBarActivity {

    //LOG_TAG
    private static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new ForecastFragment())
                    .commit();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        
        if (id == R.id.action_settings) {
            // Launch the Settings Activity
            startActivity(new Intent(this, SettingsActivity.class));
            return true;
        }

        if (id == R.id.action_map) {
            openPreferredLocationInMap();
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    private void openPreferredLocationInMap() {
        SharedPreferences sharedPrefs =
                PreferenceManager.getDefaultSharedPreferences(this);
        String location = sharedPrefs.getString(
                getString(R.string.pref_location_key),
                getString(R.string.pref_location_default));

        // Using the URI scheme for showing a location found on a map.  This super-handy
        // intent can is detailed in the "Common Intents" page of Android's developer site:
        // http://developer.android.com/guide/components/intents-common.html#Maps
        Uri geoLocation = Uri.parse("geo:0,0?").buildUpon()
                .appendQueryParameter("q", location)
                .build();

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(geoLocation);

        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            Log.d(TAG, "Couldn't call " + location + ", no receiving apps installed!");
        }
    }

}
@@ -2808,9 +2808,1044 @@
 %0A    %7D%0A%0A
+%0A    /**%0A     *  Lifecycle Methods%0A     *  - onCreate%0A     *  - onStart%0A     *  - onResume%0A     *  - onStop%0A     *  - onPause%0A     *  - onDestroy%0A     */%0A    @Override%0A    protected void onStart() %7B%0A        Log.e(TAG, %22in onStart%22);%0A        super.onStart();%0A        // The activity is about to become visible.%0A    %7D%0A%0A    @Override%0A    protected void onResume() %7B%0A        Log.e(TAG, %22in onResume%22);%0A        super.onResume();%0A        // The activity has become visible (it is now %22resumed%22).%0A    %7D%0A%0A    @Override%0A    protected void onPause() %7B%0A        Log.e(TAG, %22in onPause%22);%0A        super.onPause();%0A        // Another activity is taking focus (this activity is about to be %22paused%22).%0A    %7D%0A%0A    @Override%0A    protected void onStop() %7B%0A        Log.e(TAG, %22in onStop%22);%0A        super.onStop();%0A        // The activity is no longer visible (it is now %22stopped%22)%0A    %7D%0A%0A    @Override%0A    protected void onDestroy() %7B%0A        Log.e(TAG, %22in onDestroy%22);%0A        super.onDestroy();%0A        // The activity is about to be destroyed.%0A    %7D%0A%0A
 %7D

Use Lifecycle methods to log MainActivity's statement.