title: how to use utility class to start intent android
body: <p>I am updating code for a company app and there are about 20 activity classes that all download a PDF and then display it using this code:</p>
  
  <pre><code>public void showPdf()
  {
      File file = new File(Environment.getExternalStorageDirectory()+"/pdf/Read.pdf");
      PackageManager packageManager = getPackageManager();
      Intent testIntent = new Intent(Intent.ACTION_VIEW);
      testIntent.setType("application/pdf");
      List list = packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY);
      Intent intent = new Intent();
      intent.setAction(Intent.ACTION_VIEW);
      Uri uri = Uri.fromFile(file);
      intent.setDataAndType(uri, "application/pdf");
      startActivity(intent);
  }
  </code></pre>
  
  <p>the code is working, however it has been replicated in all 20 classes (seems very bad to me) and I would like to  put it into a single class which each activity class imports, however when I try to do this, things like <code>getPackageManager()</code> and <code>startActivity(intent)</code> no longer work.</p>
  
  <p>How can I structure my class to make this happen? or am I going about this the wrong way.</p>