private void loadingPopup() {
LayoutInflater inflater = this.getLayoutInflater();
View layout = inflater.inflate(R.layout.loading_dialog, null);
You are trying to show the pop-up window even before the activity window has been displayed. With the help of post method we can wait until all necessary start up life cycle methods get completed.
Try this :
private void loadingPopup() {
LayoutInflater inflater = this.getLayoutInflater();
final View layout = inflater.inflate(R.layout.loading_dialog, null);
final PopupWindow windows = new PopupWindow(layout , 300,300,true);
windows.setFocusable(false);
windows.setTouchable(true);
windows.setOutsideTouchable(true);
layout.post(new Runnable() {
public void run() {
windows.showAtLocation(layout,Gravity.CENTER, 0, 0);
}
});
}