I made a progress dialog that I would like appeared during synchronization. The code that starts the synchronization is this
if(check.isDeviceConnected())
{
Sincro = new Synk(this);
Sincro.start();
ProgressDialog myDialog = ProgressDialog.show(MainActivity.this, "", "Loading...");
}
I tried to put myDialog.dismiss();
after the brace, but the app crashes with a Java Null Pointer Exception
in line where it is myDialog.dismiss()
. Why? How do I make it disappear after Sync?