title: Calling main activity from non-activity class
body: <p>I've been trying many different ways and getting null pointer exceptions.</p>
  
  <p>Scenario: Activity1 loads on start and calls Activity2 if the num of rows in the table is 0. Now I want it to go back to Activity1 when the number of rows is 0 and that call would coem from the db handler.
  In the database handler class:</p>
  
  <pre><code>    if(num ==0){
          Activity1 bs1 = new Activity1();
          Context context = bs1.getApplicationContext();
          Intent intent = new Intent();//
          intent.setClass(context, Activity1.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          context.startActivity(intent);
  
      }
  </code></pre>
  
  <p>Activity1 onCreate()</p>
  
  <pre><code>    int num = db.numOfRows();
      if(num==0){
          setContentView(R.layout.main);
      } else {    
          startActivity(new Intent(this, Activity2.class));//
      }
  </code></pre>
  
  <p>Activity2 onCreate()</p>
  
  <pre><code>        super.onCreate(savedInstanceState);
          setContentView(R.layout.moreprojects);
          populateRows();
  </code></pre>
  
  <p>Thanks in advance.</p>