On Android, I'm trying to design an activity that will walk users through some system settings change. I know how to detect if the setting is enabled or not and I'll put that check in a loop in a background thread and it correct detects when the user makes the change. I want my activity to automatically pop back up to the foreground when the change happens. I have a startActivity call there but it's not working.
final Thread mSettingCheck = new Thread() {
@Override
public void run() {
try {
for (int i = 0; i < 600; i++) {
if (WizardUtils.isSettingChecked()) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(getApplicationContext(), WizardActivity.class);
startActivity(intent);
}
});
Log.i("tag", "yay!");
break;
}
sleep(500);
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
I get the log output line saying "yay" so I know it's detecting, but I don't see the activity launch to the foreground. Anyone know what I'm doing wrong?