title: Abstract class extend Thread
body: <p><strong>First question:</strong> </p>
  
  <p>How can we use </p>
  
  <p><code>ActivityManager activity =(ActivityManager)getSystemService(ForegroundApp.ACTIVITY_SERVICE)</code> </p>
  
  <p>And also 
  <code>getPackageManager</code> in a class that extends Thread?? I'm trying to fetch the Foreground activity's package name, its start time and end time in the foreground. I know this is Context based but I need to run this is in a thread.</p>
  
  <p><strong>Second Question:</strong> 
  How can we call an abstract class that extends thread in a service?? </p>
  
  <p>This thread only runs when the screen is ON. So, I'll be registering for Screen ON and OFF intents in a service. In this service, when the screen is on, i need to call this Thread.</p>
  
  <p>Example:</p>
  
  <pre><code>abstract class A extends Thread {
  
     abstract method met();
  
       public void run() {
        //Find out foreground's app name and its start and end time.
      }
  }
  
    class B extends service {
      //Here i need to call A.
  }
  </code></pre>