Fix for Android bug that causes duplicate baseactivity launches.

captchafix
Florens Douwes 11 years ago
parent f31f5df28c
commit 3349945f36
  1. 19
      Clover/app/src/main/java/org/floens/chan/ui/activity/BaseActivity.java
  2. 2
      Clover/app/src/main/java/org/floens/chan/ui/activity/BoardActivity.java

@ -34,6 +34,7 @@ import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SlidingPaneLayout; import android.support.v4.widget.SlidingPaneLayout;
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener; import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -59,8 +60,11 @@ import org.floens.chan.utils.Utils;
import java.util.List; import java.util.List;
public abstract class BaseActivity extends Activity implements PanelSlideListener, PinnedManager.PinListener { public abstract class BaseActivity extends Activity implements PanelSlideListener, PinnedManager.PinListener {
private final static String TAG = "BaseActivity";
private final static int ACTION_OPEN_URL = 1; private final static int ACTION_OPEN_URL = 1;
protected boolean wasFinished = false;
protected PinnedAdapter pinnedAdapter; protected PinnedAdapter pinnedAdapter;
protected DrawerLayout pinDrawer; protected DrawerLayout pinDrawer;
protected ListView pinDrawerView; protected ListView pinDrawerView;
@ -89,6 +93,21 @@ public abstract class BaseActivity extends Activity implements PanelSlideListene
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// See http://stackoverflow.com/a/7748416/1001608
// Possible work around for market launches. See http://code.google.com/p/android/issues/detail?id=2373
// for more details. Essentially, the market launches the main activity on top of other activities.
// we never want this to happen. Instead, we check if we are the root and if not, we finish.
if (!isTaskRoot()) {
final Intent intent = getIntent();
final String intentAction = intent.getAction();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) {
Log.w(TAG, "Activity is not the root. Finishing activity instead of launching.");
finish();
wasFinished = true;
return;
}
}
ThemeHelper.setTheme(this); ThemeHelper.setTheme(this);
ThemeHelper.getInstance().reloadPostViewColors(this); ThemeHelper.getInstance().reloadPostViewColors(this);

@ -59,6 +59,8 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (wasFinished) return;
actionBarSetToListNavigation = false; actionBarSetToListNavigation = false;
boardLoadable = new Loadable(); boardLoadable = new Loadable();
threadLoadable = new Loadable(); threadLoadable = new Loadable();

Loading…
Cancel
Save