- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试定期将我的位置值从 Android 手机发送到服务器应用程序,并将时间段设置为 1 分钟。当我开始服务时,jobservice 工作正常,但几分钟后,当我解锁手机时,Jobservice 在 1 秒内发送了两个数据。我的代码有什么问题吗
MainActivity.java
JobScheduler jobScheduler=
(JobScheduler)getSystemService(Context.JOB_SCHEDULER_SERVICE);
ComponentName jobService = new ComponentName(getPackageName(),
ServiceClass.class.getName());
JobInfo.Builder jobInfo = new JobInfo.Builder(MY_JOB, jobService);
PersistableBundle bundle = new PersistableBundle();
jobInfo.setPeriodic(period*60*1000);
int jobId = jobScheduler.schedule(jobInfo.build());
if(jobId>0){
Toast.makeText(MainActivity.this,"Successfully scheduled job
",Toast.LENGTH_SHORT).show();
btstartservice.setEnabled(false);
btstopservice.setEnabled(true);
}else{
Toast.makeText(MainActivity.this,"Faild to start service
",Toast.LENGTH_SHORT).show();
}
ServiceClass.java
public class ServiceClass extends JobService implements LocationListener{
public boolean onStartJob(JobParameters params) {
getLocation();
return false;
}
@Override
public boolean onStopJob(JobParameters params) {
Toast.makeText(getApplicationContext(),"Service
Stopped",Toast.LENGTH_SHORT).show();
return false;
}
}
最佳答案
如果您查看 JobInfo 代码,MIN_PERIOD_MILLIS设置为 15 分钟。任何低于此时间段的设置都将实际使用 15 分钟。
查看此 comment也在代码中:
Query the minimum interval allowed for periodic scheduled jobs. Attempting to declare a smaller period that this when scheduling a job will result in a job that is still periodic, but will run with this effective period.
您的间隔周期性任务将需要一些其他服务,可能警报管理器会为您工作。
关于java - 解锁手机时 Job Scheduler 在一秒钟内运行两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47152319/
有什么办法(使用CSS)在最后一步之后将 Sprite 暂停一秒或多秒?我尝试再添加一个步骤或将相同的背景位置从 80% 增加到 100%,但没有成功。 .sprite { animation:
我正在使用 Flutter 创建一个新应用,并想在初始启动画面上添加自定义图像。 图像出现在初始屏幕上,但是在大约半秒钟内它看起来被拉伸(stretch)了,看起来不太好。 我一直在寻找,但一直找不到
我有一个状态: state = { showView: false, } 如何创建一个函数,在调用时将 showView 状态更改为 true 1 秒,然后将其更改回 false? 最佳答案 this
我有一个平滑的滚动效果: jQuery('html,body').animate({scrollTop:scrollTarget}, 1000, "swing"); 它工作正常,但是当按下多个元素时,
我似乎遇到了与我之前发布的问题相同的问题。我想隐藏默认情况下存在的所有 div,只显示一个。然后用户可以单击一个侧面选项卡以显示另一个。问题是 div 在页面加载后仅隐藏一秒钟,但很快就会重新出现。这
我是一名优秀的程序员,十分优秀!