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


Java PutDataMapRequest.createWithAutoAppendedId方法代碼示例

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


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

示例1: syncTicketsToWear

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void syncTicketsToWear(String path) {
    Uri uri = Uri.parse(path);
    final ArrayList<DataMap> dataCities = new ArrayList<DataMap>();
    String cityName = uri.getLastPathSegment();

    List<City> cities = CityManager.get(getApplicationContext()).getTicketsInCity(cityName, getApplicationContext());

    for (final City city : cities) {
        final DataMap dataMap = new DataMap();
        dataMap.putLong("id", city.id);
        dataMap.putString("city", city.city);
        dataMap.putString("country", city.country);
        dataMap.putInt("validity", city.validity);
        dataMap.putString("price", city.price);
        dataMap.putString("currency", city.currency);
        dataMap.putString("price_note", city.priceNote);
        dataMap.putString("note", city.note);

        dataCities.add(dataMap);
    }
    PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/tickets");
    data.getDataMap().putDataMapArrayList("tickets", dataCities);
    syncDataItem(data);
}
 
開發者ID:avast,項目名稱:sms-ticket,代碼行數:25,代碼來源:WearableService.java

示例2: sendSmsNotification

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void sendSmsNotification(Ticket t, int status) {
    DebugLog.d("Send ticket to wear" + t.toString());
    final DataMap dataMap = new DataMap();
    dataMap.putLong("id", t.getId());
    dataMap.putLong("city_id", t.getCityId());
    dataMap.putString("city", t.getCity());
    dataMap.putInt("status", status);
    dataMap.putString("hash", t.getHash());
    dataMap.putString("text", t.getText());
    dataMap.putLong("valid_from", t.getValidFrom().toMillis(true));
    dataMap.putLong("valid_to", t.getValidTo().toMillis(true));
    dataMap.putLong("notification_id", t.getNotificationId());

    PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/notification");
    data.getDataMap().putDataMap("notification", dataMap);
    syncDataItem(data);
}
 
開發者ID:avast,項目名稱:sms-ticket,代碼行數:18,代碼來源:WearableService.java

示例3: onSave

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
@Override
public void onSave(long tweetId, String[] urls, final Handler.Callback callback) {
    PutDataMapRequest dataMap = PutDataMapRequest.createWithAutoAppendedId(Constants.PATH_POCKET_SAVE);
    dataMap.getDataMap().putStringArray("urls", urls);
    dataMap.getDataMap().putLong("id", tweetId);

    PutDataRequest request = dataMap.asPutDataRequest();
    PendingResult<DataApi.DataItemResult> pendingResult = Wearable.DataApi
            .putDataItem(mGoogleApiClient, request);
    pendingResult.setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
        @Override
        public void onResult(DataApi.DataItemResult dataItemResult) {
            Log.i(TAG, "data send status:" + dataItemResult.getStatus());
            callback.handleMessage(null);
        }
    });
}
 
開發者ID:glanceable,項目名稱:GlanceTweet,代碼行數:18,代碼來源:TweetGridPagerAdapter.java

示例4: sendError

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
/**
 * Sends error to wearable.
 */
private void sendError(String message) {
    DebugLog.e(message);
    PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/error");
    data.getDataMap().putString("error_message", message);
    syncDataItem(data);
}
 
開發者ID:avast,項目名稱:sms-ticket,代碼行數:10,代碼來源:WearableService.java

示例5: syncCitiesToWear

import com.google.android.gms.wearable.PutDataMapRequest; //導入方法依賴的package包/類
private void syncCitiesToWear() {
    CityManager cityManager = CityManager.get(getApplicationContext());
    List<City> cities = cityManager.getUniqueCities(getApplication());
    if (cities.size() > 0) {
        ArrayList<City> orderedCities = new ArrayList<>();
        LocationManager lm = (LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
        Location location = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        if (location != null) {
            City closest = cityManager.getClosest(this, location.getLatitude(), location.getLongitude());
            if (closest != null) {
                orderedCities.add(closest);

                for (int i = 0; i < cities.size(); i++) {
                    if (closest.id != cities.get(i).id) {
                        orderedCities.add(cities.get(i));
                    }
                }
            } else {
                orderedCities.addAll(cities);
            }
        }

        final ArrayList<DataMap> dataCities = new ArrayList<DataMap>();

        for (final City city : orderedCities) {
            final DataMap dataMap = new DataMap();
            dataMap.putLong("id", city.id);
            dataMap.putString("city", city.city);
            dataMap.putString("country", city.country);

            dataCities.add(dataMap);
        }

        if (dataCities.size() == 0) {
            UpdateService.call(getApplicationContext(), false);
            sendError(getResources().getString(R.string.error_zero_cities));
        } else {
            PutDataMapRequest data = PutDataMapRequest.createWithAutoAppendedId("/cities");
            data.getDataMap().putDataMapArrayList("cities", dataCities);
            syncDataItem(data);
        }

    } else {
        UpdateService.call(getApplicationContext(), false);
        sendError(getResources().getString(R.string.error_zero_cities));
    }

}
 
開發者ID:avast,項目名稱:sms-ticket,代碼行數:49,代碼來源:WearableService.java


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