title: What happened when I called a method from a subclass from the abstract superclass activity?
body: <p>I wanted to call a subclass function from within my superclass (which extends activity). However, I couldn't find the instance of the subclass, so I just naively tried to downcast my abstract superclass and call it's method to see what would happen. I didn't expect this to work - how could the superclass know which instance to call the method on?</p>
  
  <pre><code>public abstract class RootActivity extends Activity{
      private flag someCondition;
  
      @Override 
      protected void onCreate(Bundle savedInstanceState){ 
          //... 
      }
      // ... 
  
      public void startJob(JobAction.Id jobaction){
          Log.d("Zlatan", "started a job");
          if (!jobaction.someCondition){
              return;
          }else{
              ((SpecificJob) this).dontDelete(); //&lt;--- What have I done?
              startSomeLongAsynchronousJob(someCondition);
              Log.d("Zlatan", "calling finish");
              finish();
          }
  
      }
      // ...
      public void someOtherFunction(){
          finish();
      }
      @Override 
      public boolean onKeyDown(int keyCode, KeyEvent event){
          //...
          startJob(JobAction.SOMEENUM);  //Startjob is being called in the superclass
      }
  }
  }
  </code></pre>
  
  <p>I have a subclass here. The activity was launched by another activity and I've included the manifest snippet here too.  </p>
  
  <pre><code>public class SpecificJob extends SomeClassThatExtendsRootActivity{
      //SomeClassThatExtendsRootActivity extends RootActivity - I've ommitted it
      private boolean flag = false;
      @Override
      public void onCreate(Bundle bundle){
          super.onCreate(bundle);
          //...
      }
      // ... some code ...
      public void dontDelete(){ //Not static
          flag = true;
          Log.d("Zlatan", "I set flag"); //This doesn't appear in log
      }
  
      @Override 
      public void onDestroy(){
          Log.d("Zlatan", "When finishing, flag is now " + flag);
      }
  }
  
  &lt;activity
          android:name=".SpecificJob"
          android:label="@string/TXT_BOOKMARKS"
          android:icon="@drawable/ic_launcher"
          android:theme="@style/stuff"
          android:launchMode="singleTask"
          android:windowSoftInputMode="stateHidden"
          android:taskAffinity=".SpecificJob"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.me.feature.SOME_WORKFLOW" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
          &lt;/intent-filter&gt;
          &lt;meta-data
              android:name="concurrency"
              android:value="DEFAULT_CONCURRENCES|printer"
              /&gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p>To my surprise, there was no error or crash. My result was </p>
  
  <pre><code>D/Zlatan started a job
  D/Zlatan calling finish
  D/Zlatan﹕ When finishing, flag is now false
  </code></pre>
  
  <p>I dont see the log that I wrote in SpecificJob.dontDelete(). My question is </p>
  
  <p>1) What did this do at runtime? Why don't I see "I set flag", and why didn't it crash?</p>
  
  <p>2) How can I best call a function in SpecificJob from the RootActivity?</p>