First of all, I'm well aware that this error is occur because I'm trying to call window/dialog through a Context
that is not an Activity
.
But isn't there any solution to that. My requirements are; I have a Dialog
with a custom style sheet in a method of a normal JAVA class. I want to call that method from any Activity
class when I need to load the Dialog
.
In my Activity class I'm having following code set;
HomeClass homeClass = new HomeClass();
homeClass.showSplashScreen();
Then in my HomeClass I have following code set;
public void showSplashScreen() {
splashDialog = new Dialog(HomeActivity.getAppContext(), R.style.SplashScreen);
splashDialog.setContentView(R.layout.splash_screen);
splashDialog.setCancelable(false);
splashDialog.show();
}
By maintaining this design, is there any way to get rid of the WindowManager$BadTokenException
Thank You