Try passing as a context. Declare the following in your activity:
final Context context = this;
Then change:
new AlertDialog.Builder(this);
To:
new AlertDialog.Builder(context);
----------OLD ANSWER---------
Change
AlertDialog alert = builder.create();
alert.show();
To
builder.show();
As the new alert your creating is null.