title: Android: getSystemService(Context.ACTIVITY_SERVICE) is not working in Service
body: <p>I am getting a strange problem which I am not able to understand as the app does not give any crash log or any other message which I can follow to search the problem.</p>
  
  <p>I launching a service from my activity and in this service I am trying to find out the number of process which are in error state but when my code reaches to the line</p>
  
  <pre><code>ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  </code></pre>
  
  <p>then the app stops working. When I debugged my app then I found that after hitting the above line the debugger navigates to the file ActivityThread.java in cleanUpPendingRemoveWindows() with a message "Source code does not match the byte code". I am not able to understand why this is happening?</p>
  
  <p>My code is:</p>
  
  <pre><code>import android.app.ActivityManager;
  import android.app.Service;
  import android.app.usage.UsageStats;
  import android.app.usage.UsageStatsManager;
  import android.content.Context;
  import android.content.Intent;
  import android.os.IBinder;
  import android.util.Log;
  
  import java.io.IOException;
  import java.net.DatagramPacket;
  import java.net.DatagramSocket;
  import java.net.InetAddress;
  import java.net.SocketException;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.List;
  
  public class Senddata_1 extends Service {
  
  String TAG = "uEarn:Senddata_1";
  
  public void find_out_process_in_error_state(){
  
      List&lt;ActivityManager.ProcessErrorStateInfo&gt; processErrorStateInfos;
  
      ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
  
      processErrorStateInfos = am.getProcessesInErrorState();
  
      if(processErrorStateInfos != null) {
          for (ActivityManager.ProcessErrorStateInfo pes : processErrorStateInfos) {
              Log.e(TAG, "Process in Error state" + pes.processName);
              Log.e(TAG, "Process error messga" + pes.shortMsg);
  
              message = message + "&lt;p&gt;Process in Error state:" + pes.processName + ", error message:" + pes.shortMsg + "&lt;/p&gt;\n";
          }
      }
      return;
  }
  
   public Senddata_1() {
  
      // TODO: Get the Filename through the intent
  
      Log.e(TAG, "Inside service Senddata_1");
  
      find_out_process_in_error_state();
  
  }
  
  @Override
  public IBinder onBind(Intent intent) {
      // TODO: Return the communication channel to the service.
      throw new UnsupportedOperationException("Not yet implemented");
     //        return;
  }
  }
  </code></pre>