It is mContext, not context.
If it is just a mistake in your question, and you are using mContext in your project, and it still gets the Java.Lang.NullPointerException, please show more codes about where you start the new Activity. Is it a button click event?
I have tried to reproduce your question. If you just add the codes in GetView method, it still work, but your MyNewActivity will be started many time. So, please show more codes about your question.
I have posted my demo on github, you can download it and see my GetView method.
Thank You @robbit for the reply.
// image button click event.
// here I wants to open a new activity.
and MyNewActivity is calling another layout.
By AlertDialog.Builder alert1 = new AlertDialog.Builder(activity);, can you show the initialization code about activity? I have changed it to mContext, that works fine.
I have written AlertDialog.Builder alert1 = new AlertDialog.Builder(mContext); it gives the same null reference error.