I am loading some data in MainActivity and trying to show a splash screen while loading. I can't use another activity as I am loading data in main activity only, so I am using dialogs to display a picture.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
loading_dialog = new Dialog(MainActivity.this);
loading_dialog.setContentView(R.layout.loading);
loading_dialog.show();
Log.d(TAG,"show");
verifyPermissions(this);
res=new Resourses(this);
manager = new Manager(this, res);
loading_dialog.dismiss();
setContentView(R.layout.activity_main);
Log.d(TAG,"End");
view = (GLSurfaceView) findViewById(R.id.view);
view.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
view.setRenderer(manager);
additionalSkuList = new ArrayList<String>();
for(int i=0;i<10;i++)
{
additionalSkuList.add(res.id[i]);
}
String base64EncodedPublicKey;
base64EncodedPublicKey= getResources().getString(R.string.inappkey);
mHelper = new IabHelper(this, base64EncodedPublicKey);
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
// Log.d("main", "m here");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result);
}
// Hooray, IAB is fully set up!
isIAB = true;
Log.d(TAG,""+isIAB);
mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener);
// Log.d("main", "" + isIAB + " " + isLoad);
}
});
// ATTENTION: This was auto-generated to implement the App Indexing API.
// See https://g.co/AppIndexing/AndroidStudio for more information.
}
But the dialog is not displaying untill the oncreate method is done. If I run this I can't see the dialog screen. If I switch off the loading_dialog.dismiss() then its loading after all data is loaded.
Can anyone identify the problem?
SOLVED:
The problem was, setContentView doesn't initiate unless you initialize renderer's construction.
So I had to shift the data load in the GLSurfaceView's onSurfaceCreated function. Thus data got loaded after the Content view was initialized.