/*
 * Copyright 2013 Urban Airship and Contributors
 */

package com.urbanairship.richpush.sample;

import android.os.Bundle;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.actionbarsherlock.view.MenuItem;
import com.urbanairship.AirshipConfigOptions;
import com.urbanairship.UAirship;
import com.urbanairship.richpush.sample.preference.UAPreferenceAdapter;

// ActionBarSherlock does not support the new PreferenceFragment, so we fall back to using
// deprecated methods. See https://github.com/JakeWharton/ActionBarSherlock/issues/411
@SuppressWarnings("deprecation")
public class PushPreferencesActivity extends SherlockPreferenceActivity {

    private UAPreferenceAdapter preferenceAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Set the actionBar to have up navigation
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayOptions(
                    ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
        }


        AirshipConfigOptions options = UAirship.shared().getAirshipConfigOptions();
        if (options.pushServiceEnabled) {
            this.addPreferencesFromResource(R.xml.push_preferences);
        }

        if (options.locationOptions.locationServiceEnabled) {
            this.addPreferencesFromResource(R.xml.location_preferences);
        }

        preferenceAdapter = new UAPreferenceAdapter(getPreferenceScreen());
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            onBackPressed();
            return true;
        }
        return false;
    }

    @Override
    public void onStop() {
        super.onStop();

        // Apply any changed UA preferences from the preference screen
        preferenceAdapter.applyUrbanAirshipPreferences();
    }
}

@@ -1823,51 +1823,377 @@
    p
-ublic void onStop() %7B%0A        super.onStop(
+rotected void onStart() %7B%0A        super.onStart();%0A%0A        // Activity instrumentation for analytic tracking%0A        UAirship.shared().getAnalytics().activityStarted(this);%0A    %7D%0A%0A    @Override%0A    protected void onStop() %7B%0A        super.onStop();%0A%0A        // Activity instrumentation for analytic tracking%0A        UAirship.shared().getAnalytics().activityStopped(this
 );%0A%0A

Add analytic tracking for prefernce activity