From 6ce918fff36ead81cad0d86b10308ad89e8dea53 Mon Sep 17 00:00:00 2001 From: Paul Brussee Date: Sun, 7 Aug 2016 20:29:07 +0200 Subject: [PATCH] fix back button --- .../java/org/tribler/android/BaseActivity.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/android/TriblerApp/app/src/main/java/org/tribler/android/BaseActivity.java b/android/TriblerApp/app/src/main/java/org/tribler/android/BaseActivity.java index 9e9ea9e9fed..58997a1f307 100644 --- a/android/TriblerApp/app/src/main/java/org/tribler/android/BaseActivity.java +++ b/android/TriblerApp/app/src/main/java/org/tribler/android/BaseActivity.java @@ -3,10 +3,12 @@ import android.content.Intent; import android.os.Bundle; import android.support.annotation.LayoutRes; +import android.support.v4.app.NavUtils; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.MenuItem; import butterknife.BindView; import butterknife.ButterKnife; @@ -67,6 +69,20 @@ public void setContentView(@LayoutRes int layoutResID) { } } + /** + * {@inheritDoc} + */ + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Respond to the action bar's Up/Home button + if (android.R.id.home == item.getItemId() && NavUtils.getParentActivityName(this) == null) { + // Redirect SupportActionBar back button to regular back button + onBackPressed(); + return true; + } + return super.onOptionsItemSelected(item); + } + /** * {@inheritDoc} */