1

I Work on a AppLocker application and I use the function below to check the change of the top Activity But is there a better way to do it than to check every second by using "while(true)"?

   while (true) {
        String s = getlauncherTopActivity();
        if (utils.islock(s)) {

            if (!s.equals(kes)) {
                if (!s.equals(currentHomePackage) && !s.equals(this.getPackageName())) {
                    Intent dialogIntent = new Intent(this, LockAct.class);
                    dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    dialogIntent.putExtra("lock", s);
                    startActivity(dialogIntent);
                    kes = s;

                }
            }
        }

    }
Quardo
  • 11
  • 1

0 Answers0