com.google.android.gms.wearable.Wearable Java Examples
The following examples show how to use
com.google.android.gms.wearable.Wearable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DeleteQuestionService.java From android-Quiz with Apache License 2.0 | 6 votes |
@Override public void onHandleIntent(Intent intent) { mGoogleApiClient.blockingConnect(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS); Uri dataItemUri = intent.getData(); if (!mGoogleApiClient.isConnected()) { Log.e(TAG, "Failed to update data item " + dataItemUri + " because client is disconnected from Google Play Services"); return; } DataApi.DataItemResult dataItemResult = Wearable.DataApi.getDataItem( mGoogleApiClient, dataItemUri).await(); PutDataMapRequest putDataMapRequest = PutDataMapRequest .createFromDataMapItem(DataMapItem.fromDataItem(dataItemResult.getDataItem())); DataMap dataMap = putDataMapRequest.getDataMap(); dataMap.putBoolean(QUESTION_WAS_DELETED, true); PutDataRequest request = putDataMapRequest.asPutDataRequest(); request.setUrgent(); Wearable.DataApi.putDataItem(mGoogleApiClient, request).await(); mGoogleApiClient.disconnect(); }
Example #2
Source File: SunsetsWatchFaceUtil.java From american-sunsets-watch-face with Apache License 2.0 | 6 votes |
/** * Asynchronously fetches the current config {@link DataMap} for {@link SunsetsWatchFace} * and passes it to the given callback. * <p> * If the current config {@link DataItem} doesn't exist, it isn't created and the callback * receives an empty DataMap. */ public static void fetchConfigDataMap(final GoogleApiClient client, final FetchConfigDataMapCallback callback) { Wearable.NodeApi.getLocalNode(client).setResultCallback( new ResultCallback<NodeApi.GetLocalNodeResult>() { @Override public void onResult(NodeApi.GetLocalNodeResult getLocalNodeResult) { String localNode = getLocalNodeResult.getNode().getId(); Uri uri = new Uri.Builder() .scheme("wear") .path(SunsetsWatchFaceUtil.PATH_WITH_FEATURE) .authority(localNode) .build(); Wearable.DataApi.getDataItem(client, uri) .setResultCallback(new DataItemResultCallback(callback)); } } ); }
Example #3
Source File: DeleteQuestionService.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@Override public void onHandleIntent(Intent intent) { mGoogleApiClient.blockingConnect(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS); Uri dataItemUri = intent.getData(); if (!mGoogleApiClient.isConnected()) { Log.e(TAG, "Failed to update data item " + dataItemUri + " because client is disconnected from Google Play Services"); return; } DataApi.DataItemResult dataItemResult = Wearable.DataApi.getDataItem( mGoogleApiClient, dataItemUri).await(); PutDataMapRequest putDataMapRequest = PutDataMapRequest .createFromDataMapItem(DataMapItem.fromDataItem(dataItemResult.getDataItem())); DataMap dataMap = putDataMapRequest.getDataMap(); dataMap.putBoolean(QUESTION_WAS_DELETED, true); PutDataRequest request = putDataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(mGoogleApiClient, request).await(); mGoogleApiClient.disconnect(); }
Example #4
Source File: WatchUpdaterService.java From xDrip with GNU General Public License v3.0 | 6 votes |
public static void sendTreatment(double carbs, double insulin, double bloodtest, String injectionJSON, double timeoffset, String timestring) { if ((googleApiClient != null) && (googleApiClient.isConnected())) { PutDataMapRequest dataMapRequest = PutDataMapRequest.create(WEARABLE_TREATMENT_PAYLOAD); //unique content dataMapRequest.setUrgent(); dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis()); dataMapRequest.getDataMap().putDouble("carbs", carbs); dataMapRequest.getDataMap().putDouble("insulin", insulin); dataMapRequest.getDataMap().putDouble("bloodtest", bloodtest); dataMapRequest.getDataMap().putDouble("timeoffset", timeoffset); dataMapRequest.getDataMap().putString("timestring", timestring); dataMapRequest.getDataMap().putString("injectionJSON", injectionJSON); dataMapRequest.getDataMap().putBoolean("ismgdl", doMgdl(PreferenceManager.getDefaultSharedPreferences(xdrip.getAppContext()))); PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(googleApiClient, putDataRequest); } else { Log.e(TAG, "No connection to wearable available for send treatment!"); } }
Example #5
Source File: Emmet.java From Wear-Emmet with Apache License 2.0 | 6 votes |
private void sendDataMapRequest(PutDataMapRequest request) { Wearable.DataApi.putDataItem(mApiClient, request.asPutDataRequest()).setResultCallback( new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { if (dataItemResult.getStatus().isSuccess()) { if (ENABLE_LOG) Log.d(TAG, "sent"); } else { if (ENABLE_LOG) Log.d(TAG, "send error"); } } } ); }
Example #6
Source File: LoggingUtil.java From APDE with GNU General Public License v2.0 | 6 votes |
public static void broadcastMessage(final String message, final char severity, final String exception, final Context context) { handler.post(new Runnable() { public void run() { try { JSONObject json = new JSONObject(); json.put("severity", Character.toString(severity)); json.put("message", message); json.put("exception", exception); byte[] data = json.toString().getBytes(); if (bestNodeId != null) { Wearable.getMessageClient(context).sendMessage(bestNodeId, "/apde_receive_logs", data); } } catch (Exception e) { // Don't call printStackTrace() because that would make an infinite loop Log.e("apde", e.toString()); } } }); }
Example #7
Source File: WatchUpdaterService.java From xDrip with GNU General Public License v3.0 | 6 votes |
private void sendDataReceived(String path, String notification, long timeOfLastEntry, String type, long watch_syncLogsRequested) {//KS Log.d(TAG, "sendDataReceived timeOfLastEntry=" + JoH.dateTimeText(timeOfLastEntry) + " Path=" + path); forceGoogleApiConnect(); if (googleApiClient.isConnected()) { PutDataMapRequest dataMapRequest = PutDataMapRequest.create(path); dataMapRequest.setUrgent(); dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis()); dataMapRequest.getDataMap().putLong("timeOfLastEntry", timeOfLastEntry); dataMapRequest.getDataMap().putLong("syncLogsRequested", watch_syncLogsRequested); dataMapRequest.getDataMap().putString("type", type); dataMapRequest.getDataMap().putString("msg", notification); PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(googleApiClient, putDataRequest); } else { Log.e(TAG, "sendDataReceived No connection to wearable available!"); } }
Example #8
Source File: ListenerService.java From xDrip with GNU General Public License v3.0 | 6 votes |
@Override public void onDestroy() { super.onDestroy(); if (googleApiClient != null && googleApiClient.isConnected()) { googleApiClient.disconnect(); } if (googleApiClient != null) { Wearable.MessageApi.removeListener(googleApiClient, this); Wearable.ChannelApi.removeListener(googleApiClient, this); } Log.d(TAG, "Stop Sensors"); stopMeasurement(); if (mPrefs.getBoolean("enable_wearG5", true)) { Log.d(TAG, "Start BT Collection Service"); stopBtService(); } }
Example #9
Source File: IncomingRequestPhoneService.java From wear-os-samples with Apache License 2.0 | 6 votes |
private void sendMessage(String nodeId, DataMap dataMap) { Log.d(TAG, "sendMessage() Node: " + nodeId); // Clients are inexpensive to create, so in this case we aren't creating member variables. // (They are cached and shared between GoogleApi instances.) Task<Integer> sendMessageTask = Wearable.getMessageClient( getApplicationContext()).sendMessage( nodeId, Constants.MESSAGE_PATH_WEAR, dataMap.toByteArray()); sendMessageTask.addOnCompleteListener(new OnCompleteListener<Integer>() { @Override public void onComplete(Task<Integer> task) { if (task.isSuccessful()) { Log.d(TAG, "Message sent successfully"); } else { Log.d(TAG, "Message failed."); } } }); }
Example #10
Source File: ListenerService.java From xDrip with GNU General Public License v3.0 | 6 votes |
private void setLocalNodeName () { forceGoogleApiConnect(); PendingResult<NodeApi.GetLocalNodeResult> result = Wearable.NodeApi.getLocalNode(googleApiClient); result.setResultCallback(new ResultCallback<NodeApi.GetLocalNodeResult>() { @Override public void onResult(NodeApi.GetLocalNodeResult getLocalNodeResult) { if (!getLocalNodeResult.getStatus().isSuccess()) { Log.e(TAG, "ERROR: failed to getLocalNode Status=" + getLocalNodeResult.getStatus().getStatusMessage()); } else { Log.d(TAG, "getLocalNode Status=: " + getLocalNodeResult.getStatus().getStatusMessage()); Node getnode = getLocalNodeResult.getNode(); localnode = getnode != null ? getnode.getDisplayName() + "|" + getnode.getId() : ""; Log.d(TAG, "setLocalNodeName. localnode=" + localnode); } } }); }
Example #11
Source File: MainActivity.java From android-Quiz with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); mFutureQuestions = new PriorityQueue<Question>(10); // Find UI components to be used later. questionEditText = (EditText) findViewById(R.id.question_text); choiceAEditText = (EditText) findViewById(R.id.choice_a_text); choiceBEditText = (EditText) findViewById(R.id.choice_b_text); choiceCEditText = (EditText) findViewById(R.id.choice_c_text); choiceDEditText = (EditText) findViewById(R.id.choice_d_text); choicesRadioGroup = (RadioGroup) findViewById(R.id.choices_radio_group); quizStatus = (TextView) findViewById(R.id.quiz_status); quizButtons = (LinearLayout) findViewById(R.id.quiz_buttons); questionsContainer = (LinearLayout) findViewById(R.id.questions_container); readQuizFromFileButton = (Button) findViewById(R.id.read_quiz_from_file_button); resetQuizButton = (Button) findViewById(R.id.reset_quiz_button); }
Example #12
Source File: ListenerService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private void setLocalNodeName () { forceGoogleApiConnect(); PendingResult<NodeApi.GetLocalNodeResult> result = Wearable.NodeApi.getLocalNode(googleApiClient); result.setResultCallback(new ResultCallback<NodeApi.GetLocalNodeResult>() { @Override public void onResult(NodeApi.GetLocalNodeResult getLocalNodeResult) { if (!getLocalNodeResult.getStatus().isSuccess()) { Log.e(TAG, "ERROR: failed to getLocalNode Status=" + getLocalNodeResult.getStatus().getStatusMessage()); } else { Log.d(TAG, "getLocalNode Status=: " + getLocalNodeResult.getStatus().getStatusMessage()); Node getnode = getLocalNodeResult.getNode(); localnode = getnode != null ? getnode.getDisplayName() + "|" + getnode.getId() : ""; Log.d(TAG, "setLocalNodeName. localnode=" + localnode); } } }); }
Example #13
Source File: UARTService.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Sends the given message to all connected wearables. If the path is equal to {@link Constants.UART#DEVICE_DISCONNECTED} the service will be stopped afterwards. * * @param path message path * @param message the message */ private void sendMessageToWearables(@NonNull final String path, @NonNull final String message) { if (googleApiClient.isConnected()) { new Thread(() -> { NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); for (Node node : nodes.getNodes()) { Logger.v(getLogSession(), "[WEAR] Sending message '" + path + "' to " + node.getDisplayName()); final MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), path, message.getBytes()).await(); if (result.getStatus().isSuccess()) { Logger.i(getLogSession(), "[WEAR] Message sent"); } else { Logger.w(getLogSession(), "[WEAR] Sending message failed: " + result.getStatus().getStatusMessage()); Log.w(TAG, "Failed to send " + path + " to " + node.getDisplayName()); } } if (Constants.UART.DEVICE_DISCONNECTED.equals(path)) stopService(); }).start(); } else { if (Constants.UART.DEVICE_DISCONNECTED.equals(path)) stopService(); } }
Example #14
Source File: Utils.java From io2015-codelabs with Apache License 2.0 | 6 votes |
/** * Convert an asset into a bitmap object synchronously. Only call this * method from a background thread (it should never be called from the * main/UI thread as it blocks). */ public static Bitmap loadBitmapFromAsset(GoogleApiClient googleApiClient, Asset asset) { if (asset == null) { throw new IllegalArgumentException("Asset must be non-null"); } // convert asset into a file descriptor and block until it's ready InputStream assetInputStream = Wearable.DataApi.getFdForAsset( googleApiClient, asset).await().getInputStream(); if (assetInputStream == null) { Log.w(TAG, "Requested an unknown Asset."); return null; } // decode the stream into a bitmap return BitmapFactory.decodeStream(assetInputStream); }
Example #15
Source File: MessageReceiverService.java From ibm-wearables-android-sdk with Apache License 2.0 | 6 votes |
/** * Handle messages from the phone * @param messageEvent new message from the phone */ @Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/start")) { dataManager.turnSensorOn(Integer.valueOf(new String(messageEvent.getData()))); } else if (messageEvent.getPath().equals("/stop")){ dataManager.turnSensorOff(Integer.valueOf(new String(messageEvent.getData()))); } else if (messageEvent.getPath().equals("/stopAll")){ dataManager.turnAllSensorsOff(); } else if (messageEvent.getPath().equals("/ping")){ NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(apiClient).await(); for(Node node : nodes.getNodes()) { Wearable.MessageApi.sendMessage(apiClient, node.getId(), "/connected", null).await(); } } }
Example #16
Source File: DaVinci.java From DaVinci with Apache License 2.0 | 6 votes |
/** * Initialise DaVinci, muse have a googleApiClient to retrieve Bitmaps from Smartphone * * @param context the application context * @param size the number of entry on the cache */ private DaVinci(Context context, int size) { Log.d(TAG, "===================================="); this.mSize = size; this.mContext = context; this.mImagesCache = new LruCache<>(mSize); this.mDiskImageCache= new DiskLruImageCache(mContext, TAG, cacheSize, Bitmap.CompressFormat.PNG, 100); this.mPlaceHolder = new ColorDrawable(Color.TRANSPARENT); mApiClient = new GoogleApiClient.Builder(context) .addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); mApiClient.connect(); //TODO disconnect when the application close }
Example #17
Source File: WatchUpdaterService.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private void updateWearSyncBgsCapability() { CapabilityApi.GetCapabilityResult capabilityResult = Wearable.CapabilityApi.getCapability( googleApiClient, CAPABILITY_WEAR_APP, CapabilityApi.FILTER_REACHABLE).await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS); CapabilityInfo nodes; if (!capabilityResult.getStatus().isSuccess()) { Log.e(TAG, "updateWearSyncBgsCapability Failed to get capabilities, status: " + capabilityResult.getStatus().getStatusMessage()); nodes = null; } else { nodes = capabilityResult.getCapability(); } if (nodes != null && nodes.getNodes().size() > 0) { Log.d(TAG, "Updating wear sync nodes"); updateWearSyncBgsCapability(nodes); } }
Example #18
Source File: Emmet.java From Wear-Emmet with Apache License 2.0 | 6 votes |
public Emmet onCreate(Context context, ConnectionListener connectionListener) { mConnectionListener = connectionListener; mApiClient = new GoogleApiClient.Builder(context.getApplicationContext()) .addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); Wearable.MessageApi.addListener(mApiClient, new MessageApi.MessageListener() { @Override public void onMessageReceived(MessageEvent messageEvent) { onMessageReceived(messageEvent); } }); Wearable.DataApi.addListener(mApiClient, new DataApi.DataListener() { @Override public void onDataChanged(DataEventBuffer dataEventBuffer) { onDataChanged(dataEventBuffer); } }); mApiClient.connect(); return this; }
Example #19
Source File: TeslaWatchFaceService.java From rnd-android-wear-tesla with MIT License | 6 votes |
private void retrieveDeviceNode() { new Thread(new Runnable() { @Override public void run() { connectApiClient(); NodeApi.GetConnectedNodesResult result = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await(); List<Node> nodes = result.getNodes(); if (nodes.size() > 0) { mNodeId = nodes.get(0).getId(); } Log.v(TAG, "Node ID of phone: " + mNodeId); mGoogleApiClient.disconnect(); } }).start(); }
Example #20
Source File: WearActivity.java From Sensor-Data-Logger with Apache License 2.0 | 6 votes |
@Override protected void onStart() { super.onStart(); // register message handlers for (MessageHandler messageHandler : messageHandlers) { app.registerMessageHandler(messageHandler); } Wearable.MessageApi.addListener(app.getGoogleApiMessenger().getGoogleApiClient(), app); // update status status.setInForeground(true); status.updated(statusUpdateHandler); // update reachabilities of nearby nodes app.getReachabilityChecker().checkReachabilities(null); }
Example #21
Source File: UARTConfigurationsActivity.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * This method read the UART configurations from the DataApi and populates the adapter with them. */ private void populateConfigurations() { if (googleApiClient.isConnected()) { final PendingResult<DataItemBuffer> results = Wearable.DataApi.getDataItems(googleApiClient, Uri.parse("wear:" + Constants.UART.CONFIGURATIONS), DataApi.FILTER_PREFIX); results.setResultCallback(dataItems -> { final List<UartConfiguration> configurations = new ArrayList<>(dataItems.getCount()); for (int i = 0; i < dataItems.getCount(); ++i) { final DataItem item = dataItems.get(i); final long id = ContentUris.parseId(item.getUri()); final DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); final UartConfiguration configuration = new UartConfiguration(dataMap, id); configurations.add(configuration); } adapter.setConfigurations(configurations); dataItems.release(); }); } }
Example #22
Source File: MainActivity.java From wear with MIT License | 6 votes |
@Override public void onDataChanged(DataEvent event) { if (DataEvent.TYPE_CHANGED == event.getType()) { DataMapItem item = DataMapItem.fromDataItem(event.getDataItem()); Asset asset = item.getDataMap().getAsset(ASSET_KEY); ConnectionResult result = mGoogleApiClient .blockingConnect(TIMEOUT, TimeUnit.SECONDS); if (result.isSuccess()) { InputStream stream = Wearable.DataApi .getFdForAsset(mGoogleApiClient, asset) .await().getInputStream(); if (null != asset) { Bitmap bitmap = BitmapFactory.decodeStream(stream); showAsset(bitmap); } } } else if (DataEvent.TYPE_DELETED == event.getType()) { hideAsset(); } }
Example #23
Source File: MainMobileActivity.java From wear-os-samples with Apache License 2.0 | 6 votes |
private void findAllWearDevices() { Log.d(TAG, "findAllWearDevices()"); Task<List<Node>> NodeListTask = Wearable.getNodeClient(this).getConnectedNodes(); NodeListTask.addOnCompleteListener(new OnCompleteListener<List<Node>>() { @Override public void onComplete(Task<List<Node>> task) { if (task.isSuccessful()) { Log.d(TAG, "Node request succeeded."); mAllConnectedNodes = task.getResult(); } else { Log.d(TAG, "Node request failed to return any results."); } verifyNodeAndUpdateUI(); } }); }
Example #24
Source File: WatchMainActivity.java From android-wear-gopro-remote with Apache License 2.0 | 6 votes |
void findPhoneNode() { PendingResult<NodeApi.GetConnectedNodesResult> pending = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient); pending.setResultCallback(new ResultCallback<NodeApi.GetConnectedNodesResult>() { @Override public void onResult(NodeApi.GetConnectedNodesResult result) { if(result.getNodes().size()>0) { mPhoneNode = result.getNodes().get(0); if(Logger.DEBUG) Logger.debug(TAG, "Found wearable: name=" + mPhoneNode.getDisplayName() + ", id=" + mPhoneNode.getId()); sendConnectMessage(); } else { mPhoneNode = null; updateStatusUi(null); } } }); }
Example #25
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
public void onDeleteEventsClicked(View v) { if (mGoogleApiClient.isConnected()) { Wearable.DataApi.getDataItems(mGoogleApiClient) .setResultCallback(new ResultCallback<DataItemBuffer>() { @Override public void onResult(DataItemBuffer result) { if (result.getStatus().isSuccess()) { deleteDataItems(result); } else { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "onDeleteEventsClicked(): failed to get Data Items"); } } result.close(); } }); } else { Log.e(TAG, "Failed to delete data items" + " - Client disconnected from Google Play Services"); } }
Example #26
Source File: MainActivity.java From react-native-android-wear-demo with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btnIncreaseCounter = (Button) findViewById(R.id.btnWearIncreaseCounter); btnIncreaseCounter.getBackground().setColorFilter(0xFF1194F7, PorterDuff.Mode.MULTIPLY); tvCounter = (TextView) findViewById(R.id.tvCounter); tvCounter.setText(Integer.toString(count)); client = new GoogleApiClient.Builder(this).addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); btnIncreaseCounter.setOnClickListener(clickListener); }
Example #27
Source File: PhoneActivity.java From Sensor-Data-Logger with Apache License 2.0 | 6 votes |
@Override protected void onStop() { // stop data request stopRequestingSensorEventData(); // let other devices know that the app won't be reachable anymore app.getGoogleApiMessenger().sendMessageToNearbyNodes(MessageHandler.PATH_CLOSING, Build.MODEL); // unregister reachability callback app.getReachabilityChecker().unregisterReachabilityUpdateReceiver(this); // unregister message handlers for (MessageHandler messageHandler : messageHandlers) { app.unregisterMessageHandler(messageHandler); } Wearable.MessageApi.removeListener(app.getGoogleApiMessenger().getGoogleApiClient(), app); // update status status.setInForeground(false); status.updated(statusUpdateHandler); super.onStop(); }
Example #28
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mGoogleApiClient = new GoogleApiClient.Builder(this) .addApi(Wearable.API) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .build(); mFutureQuestions = new PriorityQueue<Question>(10); // Find UI components to be used later. questionEditText = (EditText) findViewById(R.id.question_text); choiceAEditText = (EditText) findViewById(R.id.choice_a_text); choiceBEditText = (EditText) findViewById(R.id.choice_b_text); choiceCEditText = (EditText) findViewById(R.id.choice_c_text); choiceDEditText = (EditText) findViewById(R.id.choice_d_text); choicesRadioGroup = (RadioGroup) findViewById(R.id.choices_radio_group); quizStatus = (TextView) findViewById(R.id.quiz_status); quizButtons = (LinearLayout) findViewById(R.id.quiz_buttons); questionsContainer = (LinearLayout) findViewById(R.id.questions_container); readQuizFromFileButton = (Button) findViewById(R.id.read_quiz_from_file_button); resetQuizButton = (Button) findViewById(R.id.reset_quiz_button); }
Example #29
Source File: WatchUpdaterService.java From xDrip with GNU General Public License v3.0 | 6 votes |
private void updateWearSyncBgsCapability() { CapabilityApi.GetCapabilityResult capabilityResult = Wearable.CapabilityApi.getCapability( googleApiClient, CAPABILITY_WEAR_APP, CapabilityApi.FILTER_REACHABLE).await(GET_CAPABILITIES_TIMEOUT_MS, TimeUnit.MILLISECONDS); CapabilityInfo nodes; if (!capabilityResult.getStatus().isSuccess()) { Log.e(TAG, "updateWearSyncBgsCapability Failed to get capabilities, status: " + capabilityResult.getStatus().getStatusMessage()); nodes = null; } else { nodes = capabilityResult.getCapability(); } if (nodes != null && nodes.getNodes().size() > 0) { Log.d(TAG, "Updating wear sync nodes"); updateWearSyncBgsCapability(nodes); } }
Example #30
Source File: RequestListenerService.java From arcgis-runtime-demos-android with Apache License 2.0 | 5 votes |
/** * Handles issuing a response to a FeatureType request. A FeatureType request * indicates that the Wear devices wants a list of available FeatureTypes for * the selected layer to display to the user. * * @param event the MessageEvent from the Wear device * @param client the Google API client used to communicate */ private void handleFeatureTypeRequest(MessageEvent event, GoogleApiClient client) { // Get the name and URL of the layer that was selected String layerName = new String(event.getData()); String url = sLayerMap.get(layerName); // Create an ArcGISFeatureLayer with the specified URL sArcGISFeatureLayer = new ArcGISFeatureLayer(url, ArcGISFeatureLayer.MODE.SNAPSHOT); // While this isn't good practice, there is no way to be notified that an // ArcGISFeatureLayer has loaded its LayerServiceInfo. The OnStatusChangedListener // seems to be more relevant when the layer is actually being added to a MapView. // As such, we simply do a quick sleep until the LayerServiceInfo has been loaded try { while (sArcGISFeatureLayer.getLayerServiceInfo() == null) { Thread.sleep(500); } } catch (Exception e) { // } // Create a PutDataMapRequest with the FeatureType response path PutDataMapRequest req = PutDataMapRequest.create(FEATURE_TYPE_RESPONSE); DataMap dm = req.getDataMap(); // Put an array list of the FeatureType names into the data map dm.putStringArrayList("featureTypes", FeatureLayerUtil.getFeatureTypes(sArcGISFeatureLayer)); // Put the current time into the data map, which forces an onDataChanged event (this event // only occurs when data actually changes, so putting the time ensures something always changes) dm.putLong("Time", System.currentTimeMillis()); // Put the DataItem into the Data API stream Wearable.DataApi.putDataItem(client, req.asPutDataRequest()); }