@Override
 public void onLicenseChecked(boolean result) {
   mLicensed = result;
   Context context = getApplicationContext();
   Editor editor = Prefs.getSettingsEditor(context);
   SharedPreferenceSaver saver = Prefs.getSettingsSaver(context);
   editor.putBoolean(Prefs.KEY_LICENSED, result);
   saver.savePreferences(editor, false);
   mHandler.sendEmptyMessage(result ? LICENSE_OK : NOT_LICENSED);
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    // Set the global application version string
    Utils.setAppVersion(this);

    PreferenceManager.setDefaultValues(this, R.xml.settings, false);

    mHandler = new SplashHandler(this);

    mHandler.sendEmptyMessage(LICENSE_CHECK);
  }
    @Override
    public void handleMessage(Message msg) {
      Splash instance = mRef.get();

      switch (msg.what) {
          /*
                      case NETWORK_CHECK:
          				// Online?
          				if (!Utils.isOnline(instance)) {
          					ErrLog.log(instance, "Splash.onCreate()", null, R.string.No_network_connection);
          					DialogFrag.newInstance(DialogFrag.Mode.OFFLINE).show(instance.getSupportFragmentManager(),
          							"offline");
          				} else {
          					this.sendEmptyMessage(NETWORK_DONE);
          				}
          				break;
          			case NETWORK_DONE:
                          mHandler.sendEmptyMessage(LICENSE_CHECK);
          				break;
          */
        case LICENSE_CHECK:
          // Check the license status, if it hasn't previously been approved
          //                    SharedPreferences settings = Prefs.getSettings(instance);
          //                    if (Version.FREE) {
          //                        instance.onLicenseChecked(true);
          //                    } else if (settings.getBoolean(Prefs.KEY_LICENSED, false)) {
          //                        instance.onLicenseChecked(true);
          //                    } else {
          //                        if (Utils.getPlatformVersion().startsWith("5")) {
          //                            // Known bug:
          // https://code.google.com/p/android/issues/detail?id=78505
          //                            Log.w(Utils.APPTAG, "SKIPPING LICENSE CHECK <" +
          // Utils.getPlatformVersion() + ">");
          //                            instance.mLicensed = true;
          //                            mHandler.sendEmptyMessage(LICENSE_OK);
          //                        } else if (Utils.isOnline(instance)) {
          //                            mProgressDialog = ProgressDialog.show(instance,
          // instance.getString(R.string.Checking_license), "",
          //                                    true);
          //                            new Thread(new CheckLicenseTask(instance),
          // "CheckLicenseTask").start();
          //                        } else {
          //                            ErrLog.log(instance, "Splash.onCreate()", null,
          // R.string.Requires_network_access_to_check_license);
          //
          // DialogFrag.newInstance(DialogFrag.Mode.LICENSE_OFFLINE).show(instance
          //                                            .getSupportFragmentManager(),
          //                                    "offline");
          //                        }
          //                    }

          // Known bug: https://code.google.com/p/android/issues/detail?id=78505
          Log.w(Utils.APPTAG, "SKIPPING LICENSE CHECK <" + Utils.getPlatformVersion() + ">");
          instance.mLicensed = true;
          mHandler.sendEmptyMessage(LICENSE_OK);
          break;
        case LICENSE_OK:
          mHandler.sendEmptyMessage(LICENSE_DONE);
          break;
        case NOT_LICENSED:
          if (mProgressDialog != null) {
            mProgressDialog.dismiss();
          }

          DialogFrag.newInstance(DialogFrag.Mode.UNLICENSED)
              .show(instance.getSupportFragmentManager(), "unlicensed");
          mHandler.sendEmptyMessage(LICENSE_DONE);
          break;
        case LICENSE_DONE:
          if (mProgressDialog != null) {
            mProgressDialog.dismiss();
          }
          if (instance.mLicensed) {
            instance.checkDatabase();
          }
          break;
        case DATABASE_CHECK:
          if (mProgressDialog != null) {
            mProgressDialog.dismiss();
          }

          if (Utils.isOnline(instance)) {
            mProgressDialog =
                ProgressDialog.show(
                    instance, instance.getString(R.string.Database_update), "", true);
            if (DbOpenHelper.isUpdating(instance)) {
              if (Prefs.getSettings(instance)
                  .getBoolean(DatabaseUpdateAlert.SHOW_DB_UPDATE_ALERT_PREF, true)) {
                new DatabaseUpdateAlert()
                    .show(instance.getSupportFragmentManager(), "databaseUpdateAlert");
              } else {
                mHandler.sendEmptyMessage(DATABASE_DONE);
              }
            } else {
              DbOpenHelper helper = DbOpenHelper.getInstance(instance);
              mDb = helper.getWritableDatabase();
            }
          } else {
            ErrLog.log(
                instance,
                "Splash.onCreate()",
                null,
                R.string.Requires_network_access_to_update_database);
            mHandler.sendEmptyMessage(DATABASE_DONE);
          }
          break;
        case DATABASE_DONE:
          if (mProgressDialog != null) {
            mProgressDialog.dismiss();
          }

          if (mDb != null) {
            mDb.close();
          }

          try {
            Thread.sleep(1250);
          } catch (InterruptedException e) {
            // Ignore
          } finally {
            instance.startActivity(new Intent(instance, MainActivity.class));
            instance.finish();
          }
          break;
      }
    }
 @Override
 public void onDbOpen() {
   mHandler.sendEmptyMessage(DATABASE_DONE);
 }
 private void checkDatabase() {
   mHandler.sendEmptyMessage(DATABASE_CHECK);
 }
 @Override
 public void onDatabaseUpdateAlert() {
   mHandler.sendEmptyMessage(DATABASE_DONE);
 }