使用警报管理器Android

问题描述

我的目标是使用AlarmManager与绑定的前台服务同步数据,以在打开应用程序时显示进度对话框,否则显示通知

我没有警报管理器就可以正常工作,但是我不知道如何使用如下所示的未决意图来绑定服务

AlarmManager alarmManager = (AlarmManager)    getSystemService(Context.ALARM_SERVICE);
        manualSyncServiceListener = new OManualSyncService.OManualSyncServiceListener();
        syncingServiceIntent = new Intent(this,OManualSyncService.class);
        if(bound){
            oManualSyncService.setListener(null); // unregister
            unbindService(serviceConnection);
            bound = false;
        }
        long frequency = 15000;
        PendingIntent pendingIntent = PendingIntent.getService(this,REQUEST_AUTOMATIC_SYNC,syncingServiceIntent,0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            alarmManager.setAndAllowWhileIdle(AlarmManager.RTC_WAKEUP,System.currentTimeMillis() + frequency,pendingIntent);
        }
        else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            alarmManager.setExact(AlarmManager.RTC_WAKEUP,frequency,pendingIntent);
        }
        else {
            alarmManager.set(AlarmManager.RTC_WAKEUP,pendingIntent);
        }

我需要这样的东西

bindService(pendingIntent,serviceConnection,Context.BIND_AUTO_CREATE);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...