title: android - startActivity using java class
body: <p>i'm having a problem with starting activity from inside java class , i want to active an activity from java class i tried this code but it doesn't work : </p>
  
  <pre><code>public class AlMA_PRO_Class{
     public static void Start_Setting(){
          ActionBarActivity mn = new MainActivity2(); // this is the setting activity
          //i've tried it like this way ==&gt;  mn.setContentView(R.layout.activity_main_activity2);
          //but not working , so i've tried this code below
          Bundle b = new Bundle();
          b.putString("command","not used , just because it's needed");
          startActivity(new Activity(), new Intent(new Activity(),MainActivity2.class), b);
     }
  }
  </code></pre>
  
  <p>and it return with the following error :</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
  </code></pre>
  
  <p>i've tested many many different ways to do it ,but nothing worked !! any help ?</p>