我正在使用JobScheduler并能够运行调度程序.
现在我想使用PersistableBundle将一些值从我的Activity传递给我的Service类.有人可以指导如何传递值并检索它吗?这是我试图传递值的函数.
private void constructJob(){
JobInfo.Builder builder = new JobInfo.Builder(JOB_ID, new ComponentName(this, MyService.class));
PersistableBundle bundle = new PersistableBundle();
bundle.putInt("height",height);
bundle.putInt("width",width);
builder.setPeriodic(20000)
.setExtras(bundle)
.setPersisted(true);
mJobScheduler.schedule(builder.build());
Run Code Online (Sandbox Code Playgroud)
}
我正在主要活动中设置工具栏,并尝试使用不同的片段更改背景颜色。因此,基本上,我试图访问片段内的工具栏对象并设置不同的背景色。我尝试做的几件事是:
访问工具栏,如:(((ActionBarActivity)getActivity())。getSupportActionBar()。setBackgroundColor(XXX);
但是我无法访问片段内的setBackgroundColor函数。它在Main Activity中完美运行。