将应用程序带回到最前面 [英] Bring application back to front
本文介绍了将应用程序带回到最前面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序是带有警报类型应用程序的计时器.计时器到期后,如果用户已经离开,但应用程序仍在运行,我想重新显示该应用程序的主要活动.
My application is a timer with alarm type app. When the timer expires i would like to bring the app's main activity back into view, if the user has navigated away, but the app is still running.
我显示了我想在哪里放置必要的代码:
I show where i would like to place the necessary code:
public class MyCount extends CountDownTimer {
public MyCount(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
public void onFinish() {
/** code here to bring the app back to the front / top of stack, in its current state */
timeDisplay.setText("Expired.!");
ReminderFlashingScreen.setVisibility(View.GONE);
statustab.setBackgroundResource(R.drawable.redtab);
seeker.setProgress(0);
reset.setBackgroundResource(R.drawable.resetbtnoff);
playExpiredAlarm();
alarmAnimation.start();
flasher.setVisibility(View.VISIBLE);
StopAlarmButtonAnimation.start();
StopAlarmButton.setVisibility(View.VISIBLE);
expired = true;
}
public void onTick(long millisUntilFinished) {
remindertimepref = prefs.getString("reminderTime", "<unset>");
remindtime = Integer.parseInt(remindertimepref.trim());
timeDisplay.setText(formatTime(millisUntilFinished));
seeker.setProgress((int) (millisUntilFinished / 1000 / 60 ) + 1);
if (used == true){
reminder_time = ((int) (millisUntilFinished / 1000));
if (reminder_time == remindtime){
reminderalarm();
used = false;
}
}
}
}
推荐答案
对我来说是这样的:
Intent intent = new Intent(Application.getContext(), AbstractFragmentActivity.instance.getClass());
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Application.getContext().startActivity(intent);
这篇关于将应用程序带回到最前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文