Context context = getApplicationContext(); KvManagerConfig config = new KvManagerConfig(context); KvManager kvManager = KvManagerFactory.getInstance().createKvManager(config); |
try { Options options = new Options(); options.setCreateIfMissing(true).setEncrypt(false).setKvStoreType(KvStoreType.SINGLE_VERSION); String storeId = “testApp”; SingleKvStore singleKvStore = kvManager.getKvStore(options, storeId); } catch (KvStoreException e) { HiLog.warn(LABEL_LOG, “getKvStore:” + e.getKvStoreErrorCode()); } |
class KvStoreObserverClient implements KvStoreObserver { @Override public void onChange(ChangeNotification notification) { List<Entry> insertEntries = notification.getInsertEntries(); List<Entry> updateEntries = notification.getUpdateEntries(); List<Entry> deleteEntries = notification.getDeleteEntries(); } } KvStoreObserver kvStoreObserverClient = new KvStoreObserverClient(); singleKvStore.subscribe(SubscribeType.SUBSCRIBE_TYPE_ALL, kvStoreObserverClient); |
try { String key = “todayWeather”; String value = “Sunny”; singleKvStore.putString(key, value); } catch (KvStoreException e) { HiLog.warn(LABEL_LOG, “putString:” + e.getKvStoreErrorCode()); } |
try { String key = “todayWeather”; String value = singleKvStore.getString(key); } catch (KvStoreException e) { HiLog.warn(LABEL_LOG, “getString:” + e.getKvStoreErrorCode()); } |
List<DeviceInfo> deviceInfoList = kvManager.getConnectedDevicesInfo(DeviceFilterStrategy.NO_FILTER); List<String> deviceIdList = new ArrayList<>(); for (DeviceInfo deviceInfo : deviceInfoList) { deviceIdList.add(deviceInfo.getId()); } singleKvStore.sync(deviceIdList, SyncMode.PUSH_ONLY); |
{ "module": { "name": "multi_camera_app", "type": "entry", "abilities": [ { "name": "com.example.multicamera.MainAbility", "icon": "$media:icon", "description": "$string:main_ability_description", "label": "$string:app_name", "type": "page", "launchType": "standard", "visible": true, "metadata": { "launch_mode": "standard" }, "skills": [ { "entities": ["entity.system.home"], "actions": ["action.system.home"] } ] } ] } } |
Intent intent = new Intent(); Operation operation = new Intent.OperationBuilder() .withDeviceId("target_device_id") .withBundleName("com.example.multicamera") .withAbilityName("com.example.multicamera.MainAbility") .build(); intent.setOperation(operation); startAbility(intent); |
Context context = getApplicationContext(); KvManagerConfig config = new KvManagerConfig(context); KvManager kvManager = KvManagerFactory.getInstance().createKvManager(config); Options options = new Options(); options.setCreateIfMissing(true).setEncrypt(false).setKvStoreType(KvStoreType.SINGLE_VERSION); String storeId = “camera_data_store”; SingleKvStore singleKvStore = kvManager.getKvStore(options, storeId); |
try { String key = “camera_1_frame_001”; String value = “frame_data_base64_string”; singleKvStore.putString(key, value); List<DeviceInfo> deviceInfoList = kvManager.getConnectedDevicesInfo(DeviceFilterStrategy.NO_FILTER); List<String> deviceIdList = new ArrayList<>(); for (DeviceInfo deviceInfo : deviceInfoList) { deviceIdList.add(deviceInfo.getId()); } singleKvStore.sync(deviceIdList, SyncMode.PUSH_ONLY); } catch (KvStoreException e) { HiLog.warn(LABEL_LOG, “putString or sync:” + e.getKvStoreErrorCode()); } |
欢迎光临 IT评测·应用市场-qidao123.com (https://dis.qidao123.com/) | Powered by Discuz! X3.4 |