In my Mainactivity:

```
 LoginUser.loginUser(username.getText().toString(),password.getText().toString(), getApplication());

```

So in my LoginUser class,
I want to start a dialog box like this:

```
new AlertDialog.Builder(context).set.....

```

but failed,
get fault info like this:

```
android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

```

Also I would like to use like

```
Intent intent = new Intent(context, ABC.class)
context.startActivity(intent);

```

Also failed. And get fault info like this:

```
android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

```

I am so confused about all of these, can anyone help me? Thank you very much!