當前位置: 首頁>>代碼示例>>Java>>正文


Java PutDataRequest.setUrgent方法代碼示例

本文整理匯總了Java中com.google.android.gms.wearable.PutDataRequest.setUrgent方法的典型用法代碼示例。如果您正苦於以下問題:Java PutDataRequest.setUrgent方法的具體用法?Java PutDataRequest.setUrgent怎麽用?Java PutDataRequest.setUrgent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.wearable.PutDataRequest的用法示例。


在下文中一共展示了PutDataRequest.setUrgent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: putConfigDataItem

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
/**
 * Overwrites the current config {@link DataItem}'s {@link DataMap} with {@code newConfig}.
 * If the config DataItem doesn't exist, it's created.
 */
public static void putConfigDataItem(GoogleApiClient googleApiClient, DataMap newConfig) {
    PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(PATH_WITH_FEATURE);
    DataMap configToPut = putDataMapRequest.getDataMap();
    configToPut.putAll(newConfig);
    PutDataRequest putDataRequest = putDataMapRequest.asPutDataRequest();
    putDataRequest.setUrgent();
    Wearable.DataApi.putDataItem(googleApiClient, putDataRequest)
            .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
                @Override
                public void onResult(DataApi.DataItemResult dataItemResult) {
                    if (Log.isLoggable(TAG, Log.DEBUG)) {
                        Log.d(TAG, "putDataItem result status: " + dataItemResult.getStatus());
                    }
                }
            });
}
 
開發者ID:marcouberti,項目名稱:adrenaline_watch_face,代碼行數:21,代碼來源:WatchFaceUtil.java

示例2: alarmCommand

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
private void alarmCommand(Intent intent) {
    AlarmCommand commandData = intent.getParcelableExtra(KEY_COMMAND_DATA);

    LiteAlarmCommand liteAlarmCommand = new LiteAlarmCommand(commandData);

    PutDataRequest putDataRequest = PutDataRequest.create(CommPaths.COMMAND_ALARM);
    putDataRequest.setData(ParcelPacker.getData(liteAlarmCommand));

    if (commandData.getIcon() != null) {
        putDataRequest.putAsset(CommPaths.ASSET_ICON, Asset.createFromBytes(commandData.getIcon()));
    }
    if (commandData.getBackgroundBitmap() != null) {
        putDataRequest.putAsset(CommPaths.ASSET_BACKGROUND, Asset.createFromBytes(commandData.getBackgroundBitmap()));
    }

    putDataRequest.setUrgent();

    Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).await();
}
 
開發者ID:matejdro,項目名稱:WearVibrationCenter,代碼行數:20,代碼來源:WatchCommander.java

示例3: sendDataItemWithoutConnectionCheck

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
/**
 * Sends payload, should be only called from this class and its subclasses
 *
 * @param path
 * @param data
 */
protected void sendDataItemWithoutConnectionCheck(DataPath path, TimeStampStorable data) {
	Logger.logD(getClass().getSimpleName(), "Sending " + path);
	PutDataRequest request = PutDataRequest.create(path.getPath());
	final byte[] dataToSend = data.getAsBytes();
	// check data size whether to send as and asset or plain data item
	if (dataToSend.length >= MAX_DATA_ITEM_SIZE_B) {
		request.putAsset(DataPath.DEFAULT_ASSET_KEY, Asset.createFromBytes(dataToSend));
	} else {
		request.setData(dataToSend);
	}
	if (path.isUrgent()) {
		request.setUrgent();
	}
	PendingResult<DataApi.DataItemResult> pendingResult =
			Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
 
開發者ID:asamm,項目名稱:locus-addon-wearables,代碼行數:23,代碼來源:LocusWearCommService.java

示例4: stopLogger

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
private void stopLogger() {
    File dir = getFilesDir();
    File[] subFiles = dir.listFiles();
    if (subFiles != null) {
        for (File file : subFiles) {
            if (file.getName().contains(recentIgcFileName)) {
                if (debugMode) Log.d(TAG, "Now checking File " + file.getName());
                Asset asset = createAssetFromTextfile(file);
                PutDataMapRequest dataMap = PutDataMapRequest.create(Statics.DATAIGC + file.getName());
                dataMap.getDataMap().putString("igcname", file.getName());
                dataMap.getDataMap().putAsset("igcfile", asset);
                PutDataRequest request = dataMap.asPutDataRequest();
                request.setUrgent();
                Wearable.DataApi.putDataItem(mGoogleApiClient, request);
            }
        }
    }
    loggerRunning = false;
    loggerState.setText("");
}
 
開發者ID:pulce,項目名稱:Wristglider,代碼行數:21,代碼來源:MainWearActivity.java

示例5: updatePreferences

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
private void updatePreferences() {
    if (debugMode) Log.d(TAG, "update Preferences");
    PutDataMapRequest dataMap = PutDataMapRequest.create(Statics.DATAPREFERENCES);
    dataMap.getDataMap().putString(Statics.PREFPILOTNAME, prefs.getString(Statics.PREFPILOTNAME, "na"));
    dataMap.getDataMap().putString(Statics.PREFGLIDERTYPE, prefs.getString(Statics.PREFGLIDERTYPE, "na"));
    dataMap.getDataMap().putString(Statics.PREFGLIDERID, prefs.getString(Statics.PREFGLIDERID, "na"));
    dataMap.getDataMap().putLong(Statics.PREFLOGGERSECONDS, prefs.getLong(Statics.PREFLOGGERSECONDS, 1000));
    dataMap.getDataMap().putBoolean(Statics.PREFLOGGERAUTO, prefs.getBoolean(Statics.PREFLOGGERAUTO, false));
    dataMap.getDataMap().putBoolean(Statics.PREFROTATEVIEW, prefs.getBoolean(Statics.PREFROTATEVIEW, false));
    dataMap.getDataMap().putBoolean(Statics.PREFSCREENON, prefs.getBoolean(Statics.PREFSCREENON, false));
    dataMap.getDataMap().putString(Statics.PREFSPEEDUNIT, prefs.getString(Statics.PREFSPEEDUNIT, "km/h"));
    dataMap.getDataMap().putString(Statics.PREFHEIGTHUNIT, prefs.getString(Statics.PREFHEIGTHUNIT, "m"));
    dataMap.getDataMap().putString(Statics.PREFROTATEDEGREES, prefs.getString(Statics.PREFROTATEDEGREES, "0"));
    dataMap.getDataMap().putBoolean(Statics.PREFUSEBTVARIO, prefs.getBoolean(Statics.PREFUSEBTVARIO, false));
    dataMap.getDataMap().putString(Statics.PREFBTVARIOUNIT, prefs.getString(Statics.PREFBTVARIOUNIT, "m/s"));
    PutDataRequest request = dataMap.asPutDataRequest();
    request.setUrgent();
    Wearable.DataApi.putDataItem(mGoogleApiClient, request);
}
 
開發者ID:pulce,項目名稱:Wristglider,代碼行數:20,代碼來源:MainActivity.java

示例6: putImageData

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
/**
 * Adds a {@code bitmap} image to a data item asynchronously. Caller can
 * specify a {@link ResultCallback} or pass a {@code null}; if a {@code null} is passed, a
 * default {@link ResultCallback} will be used (see
 * {@link #putDataItem(PutDataRequest, ResultCallback)} for details).
 *
 * @param bitmap       The bitmap to be added.
 * @param path         The path for the data item.
 * @param key          The key to be used for this item in the data map.
 * @param isUrgent     If {@code true}, request will be set as urgent.
 * @param addTimestamp If {@code true}, adds a timestamp to the data map to always create a new
 *                     data item even if an identical data item with the same bitmap has
 *                     already
 *                     been added
 * @param callback     The callback to be notified of the result (can be {@code null}).
 */
public void putImageData(Bitmap bitmap, String path, String key, boolean isUrgent,
        boolean addTimestamp,
        @Nullable ResultCallback<? super DataApi.DataItemResult> callback) {
    WearUtil.assertNotNull(bitmap, "bitmap");
    WearUtil.assertNotEmpty(path, "path");
    WearUtil.assertNotEmpty(key, "key");
    Asset imageAsset = WearUtil.toAsset(bitmap);
    PutDataMapRequest dataMap = PutDataMapRequest.create(path);
    dataMap.getDataMap().putAsset(key, imageAsset);
    if (addTimestamp) {
        dataMap.getDataMap().putLong(Constants.KEY_TIMESTAMP, new Date().getTime());
    }
    PutDataRequest request = dataMap.asPutDataRequest();
    if (isUrgent) {
        request.setUrgent();
    }
    putDataItem(request, callback);
}
 
開發者ID:csarron,項目名稱:GmsWear,代碼行數:35,代碼來源:GmsWear.java

示例7: buildWeatherRequest

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
@NonNull
private PutDataRequest buildWeatherRequest(double high, double low, Asset weatherAsset) {
    PutDataMapRequest weatherDataMapRequest = PutDataMapRequest.create(PATH_DATA_WEATHER + System.currentTimeMillis());
    DataMap weatherRequestDataMap = weatherDataMapRequest.getDataMap();
    weatherRequestDataMap.putDouble("high", high);
    weatherRequestDataMap.putDouble("low", low);
    weatherRequestDataMap.putAsset("icon", weatherAsset);
    PutDataRequest weatherRequest = weatherDataMapRequest.asPutDataRequest();
    weatherRequest.setUrgent();
    return weatherRequest;
}
 
開發者ID:chi6rag,項目名稱:SunshineWear,代碼行數:12,代碼來源:SunshineSyncAdapter.java

示例8: reportQueueChanged

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
@Override
public void reportQueueChanged(@Nullable final List<Media> queue) {
    if (mGoogleApiClient.isConnected() && queue != null && !queue.isEmpty()) {
        final WearPlaybackData.Media[] wMedias = new WearPlaybackData.Media[queue.size()];
        int i = 0;
        for (final Media media : queue) {
            wMedias[i] = toWearableMedia(media, 0);
            i++;
        }

        final PutDataRequest request;
        try {
            request = PutDataRequest.create(DataPaths.Paths.QUEUE);
            final WearPlaybackData.Queue wQueue = new WearPlaybackData.Queue();
            wQueue.media = wMedias;
            request.setData(ProtoUtils.toByteArray(wQueue));
        } catch (IOException e) {
            Log.w(TAG, e);
            return;
        }
        request.setUrgent();

        Wearable.DataApi.putDataItem(mGoogleApiClient, request).await();
    }
}
 
開發者ID:Doctoror,項目名稱:PainlessMusicPlayer,代碼行數:26,代碼來源:WearableMediaPlaybackReporter.java

示例9: handleExpressions

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
private void handleExpressions(final String path, final String expression, final String id) {
    if(validateConnection()) {
        PutDataMapRequest dataMap = PutDataMapRequest.create(path);

        dataMap.getDataMap().putString(DataMapKeys.EXPRESSION_ID, id);
        dataMap.getDataMap().putString(DataMapKeys.EXPRESSION, expression);
        dataMap.getDataMap().putLong("Time",System.currentTimeMillis());

        PutDataRequest putDataRequest = dataMap.asPutDataRequest();
        putDataRequest = putDataRequest.setUrgent();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
            @Override
            public void onResult(DataApi.DataItemResult dataItemResult) {
                Log.d(TAG, "Sending new expession ++++++++" + path +" " + id + ": " + dataItemResult.getStatus().isSuccess());
            }
        });
    }
}
 
開發者ID:swandroid,項目名稱:swan-sense-studio,代碼行數:19,代碼來源:RemoteSensorManager.java

示例10: handleSensors

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
private void handleSensors(final String path, final int sensorID, final int acuracy) {
    if(validateConnection()) {
        PutDataMapRequest dataMap = PutDataMapRequest.create(path);

        dataMap.getDataMap().putInt(SensorConstants.SENSOR_ID, sensorID);
        dataMap.getDataMap().putInt(SensorConstants.ACCURACY, acuracy);
        dataMap.getDataMap().putLong("Time",System.currentTimeMillis());

        PutDataRequest putDataRequest = dataMap.asPutDataRequest();
        putDataRequest = putDataRequest.setUrgent();
        Wearable.DataApi.putDataItem(googleApiClient, putDataRequest).setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
            @Override
            public void onResult(DataApi.DataItemResult dataItemResult) {
                Log.d(TAG, "Sending new sensor ++++++++" + path +" " + sensorID + ": " + dataItemResult.getStatus().isSuccess());
            }
        });
    }
}
 
開發者ID:swandroid,項目名稱:swan-sense-studio,代碼行數:19,代碼來源:RemoteSensorManager.java

示例11: addLocationEntry

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
private void addLocationEntry(double latitude, double longitude) {
    if (!mGpsPermissionApproved || !mGoogleApiClient.isConnected()) {
        return;
    }
    mCalendar.setTimeInMillis(System.currentTimeMillis());
    LocationEntry entry = new LocationEntry(mCalendar, latitude, longitude);
    String path = Constants.PATH + "/" + mCalendar.getTimeInMillis();
    PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(path);
    putDataMapRequest.getDataMap().putDouble(Constants.KEY_LATITUDE, entry.latitude);
    putDataMapRequest.getDataMap().putDouble(Constants.KEY_LONGITUDE, entry.longitude);
    putDataMapRequest.getDataMap()
            .putLong(Constants.KEY_TIME, entry.calendar.getTimeInMillis());
    PutDataRequest request = putDataMapRequest.asPutDataRequest();
    request.setUrgent();
    Wearable.DataApi.putDataItem(mGoogleApiClient, request)
            .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
                @Override
                public void onResult(DataApi.DataItemResult dataItemResult) {
                    if (!dataItemResult.getStatus().isSuccess()) {
                        Log.e(TAG, "AddPoint:onClick(): Failed to set the data, "
                                + "status: " + dataItemResult.getStatus()
                                .getStatusCode());
                    }
                }
            });
}
 
開發者ID:googlesamples,項目名稱:android-SpeedTracker,代碼行數:27,代碼來源:WearableMainActivity.java

示例12: sendPhoto

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
/**
 * Sends the asset that was created from the photo we took by adding it to the Data Item store.
 */
private void sendPhoto(Asset asset) {
    PutDataMapRequest dataMap = PutDataMapRequest.create(IMAGE_PATH);
    dataMap.getDataMap().putAsset(IMAGE_KEY, asset);
    dataMap.getDataMap().putLong("time", new Date().getTime());
    PutDataRequest request = dataMap.asPutDataRequest();
    request.setUrgent();

    Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);

    dataItemTask.addOnSuccessListener(new OnSuccessListener<DataItem>() {
        @Override
        public void onSuccess(DataItem dataItem) {
            LOGD(TAG, "Sending image was successful: " + dataItem);
        }
    });
}
 
開發者ID:googlesamples,項目名稱:android-DataLayer,代碼行數:20,代碼來源:MainActivity.java

示例13: sendData

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
/**
 * Sends the data, not this is a broadcast, so we will get the message as well.
 */
private void sendData(String message) {
    PutDataMapRequest dataMap = PutDataMapRequest.create(datapath);
    dataMap.getDataMap().putString("message", message);
    PutDataRequest request = dataMap.asPutDataRequest();
    request.setUrgent();

    Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);
    dataItemTask
        .addOnSuccessListener(new OnSuccessListener<DataItem>() {
            @Override
            public void onSuccess(DataItem dataItem) {
                Log.d(TAG, "Sending message was successful: " + dataItem);
            }
        })
        .addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.e(TAG, "Sending message failed: " + e);
            }
        })
    ;
}
 
開發者ID:JimSeker,項目名稱:wearable,代碼行數:26,代碼來源:MainActivity.java

示例14: sendData

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
/**
 * Sends the data.  Since it specify a client, everyone who is listening to the path, will
 * get the data.
 */
private void sendData(String message) {
    PutDataMapRequest dataMap = PutDataMapRequest.create(datapath);
    dataMap.getDataMap().putString("message", message);
    PutDataRequest request = dataMap.asPutDataRequest();
    request.setUrgent();

    Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);
    dataItemTask
        .addOnSuccessListener(new OnSuccessListener<DataItem>() {
            @Override
            public void onSuccess(DataItem dataItem) {
                Log.d(TAG, "Sending message was successful: " + dataItem);
            }
        })
        .addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Log.e(TAG, "Sending message failed: " + e);
            }
        })
    ;
}
 
開發者ID:JimSeker,項目名稱:wearable,代碼行數:27,代碼來源:MainActivity.java

示例15: sendData

import com.google.android.gms.wearable.PutDataRequest; //導入方法依賴的package包/類
/**
 * Send the sensors data to the phone
 * @param dataMapRequest data map to send
 * @return send result
 */
@Override
public PendingResult<DataApi.DataItemResult> sendData(PutDataMapRequest dataMapRequest) {
    PutDataRequest dataRequest = dataMapRequest.asPutDataRequest();
    dataRequest.setUrgent();

    return Wearable.DataApi.putDataItem(apiClient, dataRequest);
}
 
開發者ID:ibm-wearables-sdk-for-mobile,項目名稱:ibm-wearables-android-sdk,代碼行數:13,代碼來源:MessageReceiverService.java


注:本文中的com.google.android.gms.wearable.PutDataRequest.setUrgent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。