Java tutorial
package com.koboflo; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.preference.PreferenceActivity; import android.preference.PreferenceManager; import android.support.v4.app.NavUtils; import android.util.Log; import android.view.MenuItem; /** * * This Class is part of KoboFlo. * * It adds an About Dialog to the given context. * * @author Florian Hauser Copyright (C) 2014 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class SettingsActivity extends PreferenceActivity { @TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d("Preffffs", "tri"); // setContentView(R.layout.activity_type_prefs); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(true); } addPreferencesFromResource(R.xml.pref_general); PreferenceManager.setDefaultValues(SettingsActivity.this, R.xml.pref_general, false); } public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent returnIntent = new Intent(); returnIntent.putExtra("result", "justADummy"); setResult(1, returnIntent); Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Resume saved // State! NavUtils.navigateUpTo(this, intent); return true; } return super.onOptionsItemSelected(item); } }