<tfoot id='6uUJF'></tfoot>

      <bdo id='6uUJF'></bdo><ul id='6uUJF'></ul>
  1. <small id='6uUJF'></small><noframes id='6uUJF'>

    <legend id='6uUJF'><style id='6uUJF'><dir id='6uUJF'><q id='6uUJF'></q></dir></style></legend>

    1. <i id='6uUJF'><tr id='6uUJF'><dt id='6uUJF'><q id='6uUJF'><span id='6uUJF'><b id='6uUJF'><form id='6uUJF'><ins id='6uUJF'></ins><ul id='6uUJF'></ul><sub id='6uUJF'></sub></form><legend id='6uUJF'></legend><bdo id='6uUJF'><pre id='6uUJF'><center id='6uUJF'></center></pre></bdo></b><th id='6uUJF'></th></span></q></dt></tr></i><div id='6uUJF'><tfoot id='6uUJF'></tfoot><dl id='6uUJF'><fieldset id='6uUJF'></fieldset></dl></div>

      Android O:我们可以做一个时钟小部件吗?

      Android O: can we make a clock widget?(Android O:我们可以做一个时钟小部件吗?)
      • <bdo id='1skLr'></bdo><ul id='1skLr'></ul>

        <small id='1skLr'></small><noframes id='1skLr'>

          • <legend id='1skLr'><style id='1skLr'><dir id='1skLr'><q id='1skLr'></q></dir></style></legend>

              <i id='1skLr'><tr id='1skLr'><dt id='1skLr'><q id='1skLr'><span id='1skLr'><b id='1skLr'><form id='1skLr'><ins id='1skLr'></ins><ul id='1skLr'></ul><sub id='1skLr'></sub></form><legend id='1skLr'></legend><bdo id='1skLr'><pre id='1skLr'><center id='1skLr'></center></pre></bdo></b><th id='1skLr'></th></span></q></dt></tr></i><div id='1skLr'><tfoot id='1skLr'></tfoot><dl id='1skLr'><fieldset id='1skLr'></fieldset></dl></div>
                <tbody id='1skLr'></tbody>
              <tfoot id='1skLr'></tfoot>

              1. 本文介绍了Android O:我们可以做一个时钟小部件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我们的应用中有一个时钟小部件.小部件需要每分钟更新一次才能正确显示时间.

                There is a clock widget in our app. The widget needs to be updated every minute to display the time right.

                在 Android O 中,建议使用 JobScheduler 进行后台更新.不幸的是,有一些限制.

                In Android O, it is advised to use JobScheduler for background updates. Unfortunately, there are limitations.

                1. JobService 的定期更新不能在少于 15 分钟的间隔内被调用.
                2. JobService.onStartJob() 的时刻是不可预测的.我们可能会错过更新分钟数字的确切时刻(第 59 秒).

                在 O 之前,我们使用 Handler.postDelayed() 运行后台服务来更新小部件中的时间.在O中后台服务可以被系统终止.

                Prior O we used to run a background service with Handler.postDelayed() to update the time in the widget. In O the background service can be terminated by the system.

                您建议如何在 Android O 中实现时钟小部件?

                How would you recommend to implement a clock widget in Android O?

                现在还可以吗?

                推荐答案

                使用TextClock"控件,RemoteView功能支持,每分钟自动更新,无需使用那些花哨的JobScheduler作业.

                Use "TextClock" widget control, it is supported by RemoteView functionality and it updates every minute by it self, no need to use those fancy JobScheduler jobs.

                p>

                这样的事情可以解决问题:

                Something like this will do the trick:

                <LinearLayout
                    android:id="@+id/root"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
                
                    <TextClock
                        android:id="@+id/dateText"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:format12Hour="@string/date_text_format_12h"
                        android:format24Hour="@string/date_text_format_24h"
                        android:gravity="bottom|center_horizontal"
                        android:textColor="@android:color/black"
                        android:textSize="@dimen/date_text_size_default"/>
                
                    <TextClock
                        android:id="@+id/timeText"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:format12Hour="@string/time_text_format_12h"
                        android:format24Hour="@string/time_text_format_24h"
                        android:gravity="top|center_horizontal"
                        android:textColor="@android:color/black"
                        android:textSize="@dimen/time_text_size_default"
                        android:textStyle="bold"/>
                
                </LinearLayout>
                

                这篇关于Android O:我们可以做一个时钟小部件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How can I use CClistview in COCOS2d Android?(如何在 COCOS2d Android 中使用 CClistview?)
                cocos2d-android: how to display score(cocos2d-android:如何显示分数)
                Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                Android file copy(安卓文件拷贝)
                Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)
                    <tbody id='TXokk'></tbody>
                  <i id='TXokk'><tr id='TXokk'><dt id='TXokk'><q id='TXokk'><span id='TXokk'><b id='TXokk'><form id='TXokk'><ins id='TXokk'></ins><ul id='TXokk'></ul><sub id='TXokk'></sub></form><legend id='TXokk'></legend><bdo id='TXokk'><pre id='TXokk'><center id='TXokk'></center></pre></bdo></b><th id='TXokk'></th></span></q></dt></tr></i><div id='TXokk'><tfoot id='TXokk'></tfoot><dl id='TXokk'><fieldset id='TXokk'></fieldset></dl></div>
                    • <bdo id='TXokk'></bdo><ul id='TXokk'></ul>
                    • <tfoot id='TXokk'></tfoot>

                      <small id='TXokk'></small><noframes id='TXokk'>

                      <legend id='TXokk'><style id='TXokk'><dir id='TXokk'><q id='TXokk'></q></dir></style></legend>