0

MainActivity.java

public class MainActiviy extends BaseActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public void onPause() {
        super.onPause()
        // Can I avoid BaseActivity's onPause()?
    }
}

I just want to call onPause() in MainActivity skipping BaseActivity.

I cannot edit BaseActivity as it is part of a library that I'm using and removing super.onPause() in MainActivity gives error.

Maybe this is possible or maybe not so workarounds are most welcome.

Paul
  • 4,160
  • 3
  • 30
  • 56
thetanuj
  • 379
  • 2
  • 9
  • Are you asking if you can call the grandparent's onPause instead? Even if you could it would be NOT recommended- if the parent depends on its onPause being called, you'd break everything later on. – Gabe Sechan Jan 11 '17 at 13:10
  • @GabeSechan Yes, I want to call grandparent's onPause. I understand that it's not recommended but I'm willing to take that risk for now. – thetanuj Jan 11 '17 at 13:14
  • It isn't possible. If you could edit BaseActivity you could hack something in. But without that, not really. – Gabe Sechan Jan 11 '17 at 13:18
  • @AkshayBhat'AB' It would throw an exception, as its a lifecycle method that must be called. You could catch the exception but then things would break. – Gabe Sechan Jan 11 '17 at 13:19

0 Answers0