Maybe your NPE
is caused because layout and popup have not Context. Try to attach the context by using showPopUp(Context context)
as follow:
public void showPopUp (Context context) {
// ...
LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.popup);
LayoutInflater layoutInflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.send_image_popup, viewGroup);
popup = new PopupWindow(context);
// ...
}
And then, when you call this method above, do:
// pass your Activity (context)
showPopUp(MyActivity.this);
Let me know if this helps.