0

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 :

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 ==>  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);
   }
}

and it return with the following error :

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference

i've tested many many different ways to do it ,but nothing worked !! any help ?

olibiaz
  • 2,343
  • 4
  • 26
  • 29
Omar AlMA3lOl
  • 248
  • 2
  • 8
  • No mate, it's not NullPointerException !! my question is how to start activity from Class , and i've tried many codes so i post one of them – Omar AlMA3lOl Feb 24 '15 at 06:46
  • where di you get this `startActivity`-method from? I can only find them with `Intent` and `Bundle` arguments, but none with a third argument. – Soana Feb 24 '15 at 10:18

0 Answers0