android wear-Showing Information in Watch Faces and Creating InteractiveWatch Faces, Providing Confi
>Showing Information in Watch Faces
In addition to telling time, Android Wear devices provide users with contextually relevant information in the form of cards, notifications, and other wearable apps. Creating a custom watch face not only gives you the opportunity to tell time in visually compelling ways, but also to show users relevant information whenever they glance at their device.
The CalendarWatchFaceService
class obtains the number of meetings in the next day as follows:
/* Asynchronous task to load the meetings from the content provider and * report the number of meetings back using onMeetingsLoaded() */ private class LoadMeetingsTask extends AsyncTask<Void, Void, Integer> { @Override protected Integer doInBackground(Void... voids) { long begin = System.currentTimeMillis(); Uri.Builder builder = WearableCalendarContract.Instances.CONTENT_URI.buildUpon(); ContentUris.appendId(builder, begin); ContentUris.appendId(builder, begin + DateUtils.DAY_IN_MILLIS); final Cursor cursor = getContentResolver() .query(builder.build(), null, null, null, null); int numMeetings = cursor.getCount(); if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "Num meetings: " + numMeetings); } return numMeetings; } @Override protected void onPostExecute(Integer result) { /* get the number of meetings and set the next timer tick */ onMeetingsLoaded(result); } }
> This method initializes the timer when the watch face becomes visible:
@Override public void onVisibilityChanged(boolean visible) { super.onVisibilityChanged(visible); if (visible) { mLoadMeetingsHandler.sendEmptyMessage(MSG_LOAD_MEETINGS); } else { mLoadMeetingsHandler.removeMessages(MSG_LOAD_MEETINGS); cancelLoadMeetingTask(); } }
> Creating Interactive Watch Faces
Android Wear allows Android Wear watch faces to accept the single-tap gesture at a given location on the watch face, as long as there's not another UI element that also responds
to that gesture.
To provide a consistent user experience, the system reserves gestures such as drag and long-press for system UI elements. Therefore, the system does not send raw touch events
to the watch face. Instead, the system forwards specific commands to the onTapCommand() method.
> The following example shows you how to implement tap events on a watch face:
@Override public void onTapCommand( @TapType int tapType, int x, int y, long eventTime) { switch (tapType) { case WatchFaceService.TAP_TYPE_TAP: hideTapHighlight(); if (withinTapRegion(x, y)) { // Implement the tap action // (e.g. show detailed step count) onWatchFaceTap(); } break; case WatchFaceService.TAP_TYPE_TOUCH: if (withinTapRegion(x, y)) { // Provide visual feedback of touch event startTapHighlight(x, y, eventTime); } break; case WatchFaceService.TAP_TYPE_TOUCH_CANCEL: hideTapHighlight(); break; default: super.onTapCommand(tapType, x, y, eventTime); break; } }
> Providing Configurion activities
Users can choose the active watch face for their wearable device by selecting it on the companion app or using the watch face picker on the wearable device.Some
watch faces support configuration parameters to let users customize how the watch face looks and behaves
To receive updated configuration parameters from the configuration activities, create a service that implements the WearableListenerService
interface
from the Wearable Data Layer API in
your wearable app. Your watch face implementation can redraw the watch face when the configuration parameters change.
相關文章
- 人臉識別資料集 - Labeled Faces in the Wild Home (LFW)
- Creating your first iOS FrameworkiOSFramework
- Error creating bean with name ‘dataSource‘ErrorBean
- Error creating bean with name 'tomcatEmbeddedServletContainerFactory'ErrorBeanTomcatServletAI
- Error creating bean with name 解決ErrorBean
- 解決cannot find module providing package或cannot find main modulePackageAI
- Tree – Information TheoryORM
- [Information Security] What is WEPORM
- error creating overlay mount to invalid argument unbuntu系統Error
- System Volume Information是什麼檔案 System Volume Information可以刪除嗎ORM
- Error creating bean with name ‘dataSource‘: Unsatisfied dependency expressed through fieldErrorBeanExpress
- 4 Creating a Logical Standby Database 建立邏輯備庫Database
- 【MOS】Creating a PDB ... Fails With ORA-17630 (文件 ID 2090019.1)AI
- ORA-31687: error creating worker process with worker id 1Error
- [Vue] Watch and WatchEffectVue
- [Bash] watch command
- watch和computed
- computed vs watch
- watch監聽
- Linux PSI--Pressure Stall InformationLinuxORM
- Python | 資訊熵 Information EntropyPython熵ORM
- information_schema.innodb_metrics表ORM
- information_schema的結構ORM
- 學習筆記《Information Entropy》筆記ORM
- Extract rows from a CORRUPT table creating ROWID from DBA_EXTENTS
- Dynamics CRM Error- Creating Entity with an invalid parent. Entity: EmailErrorAI
- Vue computed 與 watchVue
- PostgreSQL DBA(185) - watchSQL
- Qt QMessageBox::information 自定義按鈕QTORM
- MYSQL中information_schema簡介MySqlORM
- How to Dump Redo Log File Information --metalinkORM
- 華為Watch 3智慧手錶曝光:或將命名為Watch X
- Zookeeper watch機制原理
- Zookeeper--Watch機制
- vue之computed和watchVue
- vue之watch的用法Vue
- CF466E Information Graph 題解ORM
- Variation information(資訊差異指標)ORM指標
- MySQL 進階:INFORMATION_SCHEMA 簡介MySqlORM