0

Am getting an exception when am trying to start an Activity A from FragmentActivity B. The FragmentActivity B contains two tabs.It also contains a Home button on the custom action bar. When i click on the home button it should jump to activity A. But its not working. Here is the exception.

 W/System.err(8394): java.lang.NullPointerException
 W/System.err(8394):    at android.app.Activity.startActivityForResult(Activity.java:3190)
 W/System.err(8394):    at android.app.Activity.startActivity(Activity.java:3297)
 W/System.err(8394):    at com.brihaspathi.activity.BaseActivity.gotoHomeScreen(BaseActivity.java:220)
 W/System.err(8394):    at com.brihaspathi.activity.BaseActivity$2.onClick(BaseActivity.java:208)
 W/System.err(8394):    at android.view.View.performClick(View.java:3511)
 W/System.err(8394):    at android.view.View$PerformClick.run(View.java:14105)
 W/System.err(8394):    at android.os.Handler.handleCallback(Handler.java:605)
 W/System.err(8394):    at android.os.Handler.dispatchMessage(Handler.java:92)
 W/System.err(8394):    at android.os.Looper.loop(Looper.java:137)
 W/System.err(8394):    at android.app.ActivityThread.main(ActivityThread.java:4484)
 W/System.err(8394):    at java.lang.reflect.Method.invokeNative(Native Method)
 W/System.err(8394):    at java.lang.reflect.Method.invoke(Method.java:511)
 W/System.err(8394):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788)
 W/System.err(8394):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
 W/System.err(8394):    at dalvik.system.NativeStart.main(Native Method)

And the function on Home button onclick

public void gotoHomeScreen(Activity act)
{
    try
    {
        Intent i = new Intent(act,MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(i);
        act.finish();
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}
Meenaxi
  • 567
  • 5
  • 17

0 Answers0