title: Why does getPackageManager return null
body: <p>So I am trying to start another app my inside my <code>AccessibilityService</code> but I keep getting the following <code>java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference</code> even though I use the same method in my <code>MainActivity.class</code> and it works fine. And I know the package name is correct, cause like I said I call it in <code>MainActivity.class</code></p>
  
  <p>This is the class where I call the function.</p>
  
  <pre><code>public class myAdapter extends Application
  {
     private void turnOn(String text)
     {
         Intent b = getPackageManager().getLaunchIntentForPackage(text);
         startActivity(b);
     }
  }
  </code></pre>
  
  <p>I have tried the various ways to call this same function.</p>
  
  <pre><code>Intent b = getApplicationContext().getgetPackageManager().getLaunchIntentForPackage(appName);
  getApplicationContext().startActivity(b);
  
    Intent b = getApplicationContext().getgetPackageManager().getLaunchIntentForPackage(appName);
  getApplicationContext().startActivity(b);
  </code></pre>
  
  <p>My Logcat:</p>
  
  <pre><code>Process: com.tech.myApp, PID: 17195
                                                                java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
                                                                             at android.content.ContextWrapper.getApplicationContext(ContextWrapper.java:106)
                                                                             at com.tech.myApp.turnOn(myAdapter.java:198)    
  </code></pre>