Android: different onStop conditions when overriding
<p>I have an activity that has a special <code>onStop</code> case: if the user stops the activity (only on <code>onBackPressed</code> called) it will gracefully stop and go back one level (the app has 3 levels of activities), if the user does <em>anything else</em> the activity will quit and go back to the first level. My problem is at the second level:</p>

<p>This is <code>MyActivity</code>, a class I use for different activities in my application:</p>

<pre><code>class MyActivity extends Activity {
    @Override
    protected void onStop() {
        if(!isFinishing()) {
            activityHandler.sendEmptyMessage(RESULT_CANCELED);
            finish();
        }
        super.onStop();
    }

    @Override
    public void onBackPressed() {
        if(!isFinishing()) {
            activityHandler.sendEmptyMessage(RESULT_OK);
            finish();
        }
        super.onBackPressed();
    }
}
</code></pre>

<p>Now there's my special class that should differentiate between 2 different stop conditions:</p>

<pre><code>class MySuperSpecialActivity extends MyActivity {
    private boolean launchingAnotherActivity = false;

    private void anotherActivity(String activity) {
        launchingAnotherActivity = true;
        Class&lt;?&gt; activityClass = Class.forName("com.bluetooth.activities." + activity);
        startActivityForResult(new Intent(AnotherActivity.this, activityClass), ACTIVITY);
    }

    @Override
    protected void onStop() {
        // this is what I want to override
        if(!isFinishing() &amp;&amp; !launchingAnotherActivity) {
            activityHandler.sendEmptyMessage(RESULT_CANCELED);
            finish();
        }
        // this next thing will make my app stop anyway
        super.onStop();
    }
}
</code></pre>

<p>So the <code>super.onStop()</code> part will stop my activity no matter what since the MyActivity class doesn't have the <code>launchingAnotherActivity</code> condition... How could I override the <code>onStop</code> without it finishing my activity?</p>
