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.
相關文章
- android wear-Drawing Watch FacesAndroid
- JavaServer Faces Note(1)JavaServer
- JavaServer Faces Note(2)JavaServer
- adroid Wear-Designing Watch Faces and Building a Watch Face ServiceUI
- ORL Faces Database介紹Database
- ADF FACES 佈局
- 用JavaServer Faces開發Web應用(4) (轉)JavaServerWeb
- 用JavaServer Faces開發Web應用(3) (轉)JavaServerWeb
- android TV - Creating a Catalog Browser,Providing a Card ViewAndroidView
- 將Oracle ADF Faces整合到Appfuse裡面OracleAPP
- javax.faces.FacesException: Nested form found on the page. The form action elemeJavaExceptionORM
- 人臉識別資料集 - Labeled Faces in the Wild Home (LFW)
- Miscellaneous Information about Creating Indexes on Partitioned TablesORMIndex
- android-Providing Up Navigation,Providing Proper Back NavigationAndroidNavigation
- android auto-Providing Audio Playback for AutoAndroid
- Some Chinese Android Developers InformationAndroidDeveloperORM
- android-Creating a Navigation DrawerAndroidNavigation
- android auto-Providing Messaging for Auto(UnreadConversation)Android
- android-Planning for Multiple Touchscreen Sizes,Providing Descendant and Lateral NavigationAndroidNavigation
- Android TV-Creating TV NavigationAndroidNavigation
- android-Creating Multiple APKs for Different Screen Sizes,Creating Multiple APKs for Different GL TeAndroidAPK
- android-Providing Ancestral and Temporal Navigation,Putting it All Together: Wireframing the ExampleAndroidNavigation
- Uncertainy and informationAIORM
- android-Implementing Effective Navigation,Creating Swipe Views with TabsAndroidNavigationView
- android-Maintaining Multiple APKs,Creating Multiple APKs for Different API LevelsAndroidAIAPKAPI
- Creating the Database (58)Database
- [Information Security] What is WEPORM
- Oracle Lock Information QueriesOracleORM
- 谷歌Android Wear 2.0功能曝光:HUAWEI Watch首批支援谷歌Android
- Creating a Physical Standby DatabaseDatabase
- Creating Secondary IndexesIndex
- Creating the SYSAUX Tablespace (72)UX
- Detailed Information on ODS and DSO objectAIORMObject
- Creating your first iOS FrameworkiOSFramework
- Error creating bean with name ‘dataSource‘ErrorBean
- Creating External Lists From Code
- Creating Test Script With Bind Variable
- Creating an Index OnlineIndex