Android 主页小部件未使用JobIntentService在Oreo上刷新
我的应用程序包含使用Android 主页小部件未使用JobIntentService在Oreo上刷新,android,android-widget,android-intentservice,jobintentservice,Android,Android Widget,Android Intentservice,Jobintentservice,我的应用程序包含使用IntentService定期更新的主页小部件 现在,当我瞄准API级别26时,由于Oreo的限制,我不得不稍微改变一下。你可以找到更多信息 我发现其中描述了如何使IntentService在Oreo上工作 我做了所描述的一切: 已将我的IntentService转换为JobIntentService 将所有逻辑从onHandleIntent()移动到onHandleWork() 将android:permission=“android.permission.BIND_JO
IntentService
定期更新的主页小部件
现在,当我瞄准API级别26时,由于Oreo的限制,我不得不稍微改变一下。你可以找到更多信息
我发现其中描述了如何使IntentService在Oreo上工作
我做了所描述的一切:
- 已将我的
转换为IntentService
JobIntentService
- 将所有逻辑从
移动到onHandleIntent()
onHandleWork()
- 将
添加到AndroidManifest文件中的服务android:permission=“android.permission.BIND_JOB_SERVICE”
- 此外,
已在本项目中使用 - 我更进一步,开始使用以下逻辑启动服务:
enqueueWork(context,LocationForecastService.class,JOB_ID,work)代码>
<receiver
android:name=".widgets.provider.WeekWidgetProvider"
android:label="@string/Widget_WeekForecast_Title">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="action_widget_data_change_event" />
<action android:name="action_week_widget_data_change_event" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/appwidget_week_provider_layout" />
</receiver>
有人遇到过类似的问题吗?为了使这项工作正常进行,我必须按照上面问题中提供的URL实现所有内容 在打算发送广播时,一定要小心 而不是
Intent intent = new Intent(action);
应使用以下代码:
Intent intent = new Intent(context, clazz);
intent.setAction(action);
其中
clazz
是widget provider类。显示您将广播发送给接收者的代码。您的工作正常吗?此外,正如@HeyAlex所说,您没有向我们展示代码如何从JobIntentService
@PrimožKralj currenlty返回数据,而不是在具有源代码的计算机上,但我做了上面提到的链接文章“本文”链接中解释的一切。