如何让我的应用偶尔弹出

时间:2014-10-25 10:31:10

标签: java android background-process pop

如何让我的应用偶尔弹出? 我的意思是应用程序将在后台运行,偶尔(在X秒后)应用程序将弹出..

这可能吗?

2 个答案:

答案 0 :(得分:0)

是的,有可能,User android Alarm manager服务。以下是有关Alarm manager

的详细信息

答案 1 :(得分:0)

创建服务并覆盖onStartCommand:

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        timer = new CountDownTimer(5 * 60 * 1000, 1000) { //Opens popup every 5 mins

            @Override
            public void onTick(long millisUntilFinished) {

            }

            @Override
            public void onFinish() {
                //Open your popup here
                timer.cancel();
                timer.start();
            }
        };
        timer.start();
        return START_STICKY;
    }