I am developing a paid app, which checks for the license upon starting (from onCreate() method) the app. After receiving the response codes from server, the subsequent callback methods allow(), dontAllow(), applicationError() executes which contains different Toasts.
Now my question is that whenever any Toasts gets generated and if suddenly I press device's back Button before the finishing off the Toast then the Toast gets stuck on the screen. It gets finished off only when I remove the app from task list.
private class XYZLicenseCheckerCallback implements LicenseCheckerCallback {
@Override
public void allow(int reason) {
if(isFinishing()) {
return;
}
Toast.makeText(XyzActivity.this,"App purchase verified",Toast.LENGTH_SHORT).show();
System.out.println("allowed called"+reason);
}
@Override
public void dontAllow(int reason) {
if(isFinishing()) {
return;
}
displayResult(String.valueOf(reason));
stopService(serviceIntent);
Toast.makeText(XyzActivity.this,"App not licensed",Toast.LENGTH_SHORT).show();
System.out.println("don't allow called"+reason);
}
@Override
public void applicationError(int errorCode) {
if(isFinishing()) {
return;
}
Toast.makeText(XyzActivity2108.this,"Not able to verify the license,check your internet connection",Toast.LENGTH_SHORT).show();
// finish();
System.out.println("app error called"+errorCode);
}
}
Here is my onBackpressed() method
@Override
public void onBackPressed() {
finish();
}
Any help from your side please?