source stringlengths 14 113 | code stringlengths 10 21.3k |
|---|---|
application-dev\dfx\hiappevent-watcher-freeze-events-arkts.md | hiAppEvent.addWatcher({
// Set the watcher name. The system identifies different watchers based on their names.
name: "watcher",
// Add the system events to watch, for example, freeze events.
appEventFilters: [
{
domain: hiAppEvent.domain.OS,
names: [hiAppEvent.event.... |
application-dev\dfx\hiappevent-watcher-freeze-events-arkts.md | Button("appFreeze").onClick(()=>{
// Construct a scenario in onClick() for triggering a freeze event.
setTimeout(() => {
while (true) {}
}, 1000)
}) |
application-dev\dfx\hiappevent-watcher-mainthreadjank-events-arkts.md | import { hiAppEvent } from '@kit.PerformanceAnalysisKit'; |
application-dev\dfx\hiappevent-watcher-mainthreadjank-events-arkts.md | hiAppEvent.addWatcher({
// Set the watcher name. The system identifies different watchers based on their names.
name: "watcher",
// Add the system events to watch, for example, the main thread jank event.
appEventFilters: [
{
domain: hiAppEvent.domain.OS,
names: [hiAp... |
application-dev\dfx\hiappevent-watcher-mainthreadjank-events-arkts.md | @Entry
@Component
struct Index {
build() {
RelativeContainer() {
Column() {
Button("timeOut350", { stateEffect:true, type: ButtonType.Capsule})
.width('75%')
.height(50)
.margin(15)
.fontSize(20)
... |
application-dev\dfx\hiappevent-watcher-mainthreadjank-events-arkts.md | import { hiAppEvent, hilog } from '@kit.PerformanceAnalysisKit';
import { BusinessError } from '@kit.BasicServicesKit';
// Simulate a main thread jank event.
function wait150ms() {
let t = Date.now();
while (Date.now() - t <= 150){
}
}
function wait500ms() {
... |
application-dev\dfx\hiappevent-watcher-resourceleak-events-arkts.md | import { hiAppEvent, hilog, hidebug } from '@kit.PerformanceAnalysisKit'; |
application-dev\dfx\hiappevent-watcher-resourceleak-events-arkts.md | hiAppEvent.addWatcher({
// Set the watcher name. The system identifies different watchers based on their names.
name: "watcher",
// Add the system events to watch, for example, the resource leak event.
appEventFilters: [
{
domain: hiAppEvent.domain.OS,
names: [hiAppEv... |
application-dev\dfx\hiappevent-watcher-resourceleak-events-arkts.md | import hidebug from "@ohos.hidebug";
@Entry
@Component
struct Index {
@State leakedArray: string[][] = [];
build() {
Column() {
Row() {
Column() {
Button("pss leak")
.onClick(() => {
hidebug.setAppResourceLimit("pss_... |
application-dev\dfx\hiappevent-watcher-resourceleak-events-ndk.md | import hidebug from "@ohos.hidebug";
@Entry
@Component
struct Index {
@State leakedArray: string[][] = [];
build() {
Column() {
Row() {
Column() {
Button("pss leak")
.onClick(() => {
hidebug.setAppResourceLimit("pss_... |
application-dev\dfx\hichecker-guidelines-arkts.md | import { window } from '@kit.ArkUI';
import { image } from '@kit.ImageKit';
import { UIAbility, Want, AbilityConstant } from '@kit.AbilityKit';
import { hichecker, hilog } from '@kit.PerformanceAnalysisKit';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: Abi... |
application-dev\dfx\hicollie-guidelines-ndk.md | import testNapi from 'libentry.so'
@Entry
@Component
struct Index {
build() {
RelativeContainer() {
Column() {
//Add the click event corresponding to the detection.
}.width('100%')
}
.height('100%')
.width('100%')
}
} |
application-dev\dfx\hicollie-guidelines-ndk.md | Button("testHiCollieJankNdk", { stateEffect:true, type: ButtonType.Capsule})
.width('75%')
.height(50)
.margin(15)
.fontSize(20)
.fontWeight(FontWeight.Bold)
.onClick(testNapi.testHiCollieJankNdk); |
application-dev\dfx\hicollie-guidelines-ndk.md | Button("testHiCollieStuckNdk", { stateEffect:true, type: ButtonType.Capsule})
.width('75%')
.height(50)
.margin(15)
.fontSize(20)
.fontWeight(FontWeight.Bold)
.onClick(testNapi.testHiCollieStuckNdk); |
application-dev\dfx\hicollie-guidelines-ndk.md | Button("testHiCollieStuckWithTimeoutNdk", { stateEffect:true, type: ButtonType.Capsule})
.width('75%')
.height(50)
.margin(15)
.fontSize(20)
.fontWeight(FontWeight.Bold)
.onClick(testNapi.testHiCollieStuckWithTimeoutNdk); |
application-dev\dfx\hicollie-settimer-guidelines-ndk.md | export const TestHiCollieTimerNdk: () => void; |
application-dev\dfx\hicollie-settimer-guidelines-ndk.md | import testNapi from 'libentry.so';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Button("TestHiCollieTimerNdk")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(testNa... |
application-dev\dfx\hidebug-guidelines-arkts.md | import { hidebug } from '@kit.PerformanceAnalysisKit';
import { BusinessError } from '@kit.BasicServicesKit';
function testHiDebug(event?: ClickEvent) {
try {
console.info(`getSystemCpuUsage: ${hidebug.getSystemCpuUsage()}`);
} catch (error) {
console.error(`error code: ${(error as Busines... |
application-dev\dfx\hidebug-guidelines-arkts.md | @Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(testHiDebug);// Add a click event.
}
.width('1... |
application-dev\dfx\hidebug-guidelines-ndk.md | import testNapi from 'libentry.so';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(testNapi.testHiDeb... |
application-dev\dfx\hidebug-guidelines-ndk.md | import testNapi from 'libentry.so';
function testJsFrame(i : number) : void {
if (i > 0) {
testJsFrame(i - 1);
return;
}
testNapi.testHiDebugNdk();
}
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column(... |
application-dev\dfx\hilog-guidelines-arkts.md | // Index.ets
import { hilog } from '@kit.PerformanceAnalysisKit';
@Entry
@Component
struct Index {
build() {
Row() {
Column() {
// Add a button named Next.
Button() {
Text('Next')
.fontSize(30)
.fontWeight(FontWeig... |
application-dev\dfx\hitracechain-guidelines-arkts.md | import { BusinessError } from '@kit.BasicServicesKit';
import { hiAppEvent, hilog, hiTraceChain } from '@kit.PerformanceAnalysisKit';
@Entry
@Component
struct Index {
@State message: string = 'Start writing an app event';
build() {
Row() {
Column() {
Button(th... |
application-dev\dfx\hitracemeter-guidelines-arkts.md | import { hiTraceMeter, hilog } from '@kit.PerformanceAnalysisKit';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
... |
application-dev\dfx\jscrash-guidelines.md | // Update the gesture value.
public updateGestureValue(screenWidth: number, recentScale: number, sceneContainerSessionList: SCBSceneContainerSession[]) {
// Calculate the moving distance of the hand.
this.translationUpY = (this.multiCardsNum >= 1)? sceneContainerSessionList[this.multiCardsNum - 1]... |
application-dev\dfx\jscrash-guidelines.md | // Update the gesture value.
public updateGestureValue(screenWidth: number, recentScale: number, sceneContainerSessionList: SCBSceneContainerSession[]) {
// Calculate the moving distance of the hand.
this.translationUpY = (this.multiCardsNum >= 1) ?
sceneContainerSessionList[this.multiCardsNum -... |
application-dev\dfx\jscrash-guidelines.md | throw new Error("TEST JS ERROR") |
application-dev\dfx\jscrash-guidelines.md | onStart(): void {
super.onStart();
log.showInfo('onStart');
// ...
wifiManager.on('wifiConnectionChange', (data) => {
this.isConnected = data === 1 ? true : false;
this.handleUpdateState();
});
wifiManager.on('wifiStateChange', (data) => {
this.isWifiActive = ... |
application-dev\dfx\jscrash-guidelines.md | onStart(): void {
super.onStart();
log.showInfo('onStart');
// ...
try {
wifiManager.on('wifiConnectionChange', (data) => {
this.isConnected = data === 1 ? true : false;
this.handleUpdateState();
});
} catch (error) {
log.showError('wifiConnectio... |
application-dev\displaymanager\screenProperty-guideline.md | import { display } from '@kit.ArkUI';
let displayClass: display.Display | null = null;
displayClass = display.getDefaultDisplaySync();
// Ensure that the display object, displayClass in this example, is obtained before the operations of querying the display properties and listening for events and status changes. |
application-dev\displaymanager\screenProperty-guideline.md | import { display } from '@kit.ArkUI';
let displayClass: display.Display | null = null;
displayClass = display.getDefaultDisplaySync();
// Obtain the display ID.
console.info(`The screen Id is ${displayClass.id}.`);
// Obtain the refresh rate.
console.info(`The screen is ${displayClass.refreshR... |
application-dev\displaymanager\screenProperty-guideline.md | import { BusinessError } from '@kit.BasicServicesKit';
displayClass.getCutoutInfo().then((cutoutInfo: display.CutoutInfo) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(cutoutInfo));
}).catch((err: BusinessError) => {
console.error(`Failed to obtain all the display obje... |
application-dev\displaymanager\screenProperty-guideline.md | console.info(`The screen is captured or not : ${display.isCaptured()}`); |
application-dev\displaymanager\screenProperty-guideline.md | import { display } from '@kit.ArkUI';
import { Callback } from '@kit.BasicServicesKit';
let callback1: Callback<number> = (data: number) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data));
};
// The following uses the addition event as an example.
display.on("add", callback1);... |
application-dev\displaymanager\screenProperty-guideline.md | let callback2: Callback<boolean> = (captureStatus: boolean) => {
// For captureStatus, the value true means that the device starts screen capture, casting, or recording, and false means that the device stops screen capture, casting, or recording.
console.info('Listening capture status: ' + captureStatus);
... |
application-dev\displaymanager\screenProperty-guideline.md | import { Callback } from '@kit.BasicServicesKit';
import { display } from '@kit.ArkUI';
let callback3: Callback<display.Rect> = (data: display.Rect) => {
console.info('Listening enabled. Data: ' + JSON.stringify(data));
};
let displayClass: display.Display | null = null;
try {
displayClass ... |
application-dev\displaymanager\screenProperty-guideline.md | import { Callback } from '@kit.BasicServicesKit';
/**
* The callback parameter used for subscription must be passed as an object.
* If an anonymous function is used for registration, a new underlying object is created each time the function is called, causing memory leakage.
*/
let callback: Callba... |
application-dev\displaymanager\virtualScreen-guideline.md | import { BusinessError } from '@kit.BasicServicesKit';
import { screen } from '@kit.ArkUI';
@Entry
@Component
struct VirtualScreen {
xComponentController: XComponentController = new XComponentController();
build() {
RelativeContainer() {
Column() {
XComponent({
type: XComponentType.SUR... |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { abilityConnectionManager } from '@kit.DistributedServiceKit'; |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { abilityConnectionManager, distributedDeviceManager } from '@kit.DistributedServiceKit';
import { common } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
let dmClass: distributedDeviceManager.DeviceManager;
function initDmClass(): void {
try {
dmClass = distribu... |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
import { abilityConnectionManager } from '@kit.DistributedServiceKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam):... |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { abilityConnectionManager } from '@kit.DistributedServiceKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
abilityConnectionManager.on("connect", this.sessionId,(callbackInfo) => {
hilog.info(0x0000, 'testTag', 'session connect, sessionId is', callbackInfo.sessionId);
});
abilityConnection... |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { abilityConnectionManager } from '@kit.DistributedServiceKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
abilityConnectionManager.sendMessage(this.sessionId, "message send success").then(() => {
hilog.info(0x0000, 'testTag', "sendMessage success");
}).catch(() => {
hilog.error(0x0000, ... |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { abilityConnectionManager } from '@kit.DistributedServiceKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
let textEncoder = util.TextEncoder.create("utf-8");
const arrayBuffer = textEncoder.encodeInto("data send success");
abilityConnectionManager.sendData(this.sessionId, arrayBuffer.buffer... |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { abilityConnectionManager } from '@kit.DistributedServiceKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import CameraService from '../model/CameraService';
import { photoAccessHelper } from '@kit.MediaLibraryKit';
import { image } from '@kit.ImageKit';
import { fileIo as fs } from '@kit.Co... |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { abilityConnectionManager } from '@kit.DistributedServiceKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
hilog.info(0x0000, 'testTag', 'startStream');
abilityConnectionManager.createStream(sessionId ,{name: 'receive', role: 0}).then(async (streamId) => {
let surfaceParam: abilityConnection... |
application-dev\distributedservice\abilityconnectmanager-guidelines.md | import { abilityConnectionManager } from '@kit.DistributedServiceKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
hilog.info(0x0000, 'testTag', 'disconnectRemoteAbility begin');
if (this.sessionId == -1) {
hilog.info(0x0000, 'testTag', 'Invalid session ID.');
return;
}
abilityConnectionManage... |
application-dev\distributedservice\camera-distributed.md | import { camera } from '@kit.CameraKit';
import { media } from '@kit.MediaKit'; |
application-dev\distributedservice\camera-distributed.md | //EntryAbility.ets
export default class EntryAbility extends UIAbility {
onCreate(want, launchParam) {
Logger.info('Sample_VideoRecorder', 'Ability onCreate,requestPermissionsFromUser');
let permissionNames: Array<Permissions> = ['ohos.permission.MEDIA_LOCATION', 'ohos.permission.READ_MEDIA',
... |
application-dev\distributedservice\camera-distributed.md | private cameras?: Array<camera.CameraDevice>;
private cameraManager?: camera.CameraManager;
private cameraOutputCapability?: camera.CameraOutputCapability;
private cameraIndex: number = 0;
private curVideoProfiles?: Array<camera.VideoProfile>;
function initCamera(): void {
console.info('init remote camer... |
application-dev\distributedservice\camera-distributed.md | // create camera input
async createCameraInput(): Promise<void> {
console.log('createCameraInput called');
if (this.cameras && this.cameras.length > 0) {
let came: camera.CameraDevice = this.cameras[this.cameraIndex];
console.log('[came]createCameraInput camera json:', JSON.stringify(came));
... |
application-dev\distributedservice\camera-distributed.md | private previewOutput?: camera.PreviewOutput;
private avConfig: media.AVRecorderConfig = {
videoSourceType: media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
profile: this.avProfile,
url: 'fd://',
}
// create camera preview
async createPreviewOutput(): Promise<void> {
console.log('createPrev... |
application-dev\distributedservice\camera-distributed.md | import fileio from '@ohos.fileio';
private photoReceiver?: image.ImageReceiver;
private photoOutput?: camera.PhotoOutput;
private mSaveCameraAsset: SaveCameraAsset = new SaveCameraAsset('Sample_VideoRecorder');
async getImageFileFd(): Promise<void> {
console.info'getImageFileFd called');
this.mFileAss... |
application-dev\distributedservice\camera-distributed.md | private captureSession?: camera.CaptureSession;
function failureCallback(error: BusinessError): Promise<void> {
console.log('case failureCallback called,errMessage is ', json.stringify(error));
}
function catchCallback(error: BusinessError): Promise<void> {
console.log('case catchCallback called,errMess... |
application-dev\distributedservice\camera-distributed.md | // start captureSession
async startCaptureSession(): Promise<void> {
console.log('startCaptureSession called');
if (!this.captureSession) {
console.log('CaptureSession does not exists!');
return
}
await this.captureSession.start().then(() => {
console.log('case start captureSession s... |
application-dev\distributedservice\camera-distributed.md | // Release the camera.
async releaseCameraInput(): Promise<void> {
console.log('releaseCameraInput called');
if (this.cameraInput) {
this.cameraInput = undefined;
}
console.log('releaseCameraInput done');
}
// Release the preview.
async releasePreviewOutput(): Promise<void> {
console.... |
application-dev\distributedservice\devicemanager-guidelines.md | {
"module" : {
"requestPermissions":[
{
"name" : "ohos.permission.DISTRIBUTED_DATASYNC",
"reason": "$string:distributed_permission",
"usedScene": {
"abilities": [
"MainAbility"
],
"when": "inuse"
}
... |
application-dev\distributedservice\devicemanager-guidelines.md | import { common, abilityAccessCtrl } from '@kit.AbilityKit'; |
application-dev\distributedservice\devicemanager-guidelines.md | let context = getContext(this) as common.UIAbilityContext;
let atManager = abilityAccessCtrl.createAtManager();
try {
atManager.requestPermissionsFromUser(context, ['ohos.permission.DISTRIBUTED_DATASYNC']).then((data) => {
console.log('data: ' + JSON.stringify(data));
}).catch((err: object) => {
... |
application-dev\distributedservice\devicemanager-guidelines.md | import { distributedDeviceManager } from '@kit.DistributedServiceKit'; |
application-dev\distributedservice\devicemanager-guidelines.md | import { BusinessError } from '@kit.BasicServicesKit'; |
application-dev\distributedservice\devicemanager-guidelines.md | try {
let dmInstance = distributedDeviceManager.createDeviceManager('ohos.samples.jsHelloWorld');
dmInstance.on('discoverSuccess', data => console.log('discoverSuccess on:' + JSON.stringify(data)));
dmInstance.on('discoverFailure', data => console.log('discoverFailure on:' + JSON.stringify(data)));
} ... |
application-dev\distributedservice\devicemanager-guidelines.md | interface DiscoverParam {
discoverTargetType: number;
}
interface FilterOptions {
availableStatus: number;
discoverDistance: number;
authenticationStatus: number;
authorizationType: number;
}
let discoverParam: Record<string, number> = {
'discoverTargetType': 1
};
let fil... |
application-dev\distributedservice\devicemanager-guidelines.md | class Data {
deviceId: string = '';
}
let deviceId = 'XXXXXXXX';
let bindParam: Record<string, string | number> = {
'bindType': 1,
'targetPkgName': 'xxxx',
'appName': 'xxxx',
'appOperation': 'xxxx',
'customDescription': 'xxxx'
};
try {
dmInstance.bindTarget(deviceId, b... |
application-dev\distributedservice\devicemanager-guidelines.md | try {
let deviceInfoList: Array<distributedDeviceManager.DeviceBasicInfo> = dmInstance.getAvailableDeviceListSync();
} catch (err) {
let e: BusinessError = err as BusinessError;
console.error('getAvailableDeviceListSync errCode:' + e.code + ',errMessage:' + e.message);
} |
application-dev\distributedservice\devicemanager-guidelines.md | import { distributedDeviceManager } from '@kit.DistributedServiceKit'; |
application-dev\distributedservice\devicemanager-guidelines.md | import { BusinessError } from '@kit.BasicServicesKit'; |
application-dev\distributedservice\devicemanager-guidelines.md | try {
let dmInstance = distributedDeviceManager.createDeviceManager('ohos.samples.jsHelloWorld');
dmInstance.on('deviceStateChange', data => console.log('deviceStateChange on:' + JSON.stringify(data)));
} catch(err) {
let e: BusinessError = err as BusinessError;
console.error('createDeviceManager... |
application-dev\distributedservice\distributedextension-guidelines.md | import { AbilityConstant, Want } from '@kit.AbilityKit';
import { abilityConnectionManager, DistributedExtensionAbility } from '@kit.DistributedServiceKit'; |
application-dev\distributedservice\distributedextension-guidelines.md | import { AbilityConstant, Want } from '@kit.AbilityKit';
import { abilityConnectionManager, DistributedExtensionAbility } from '@kit.DistributedServiceKit';
export default class DistributedExtension extends DistributedExtensionAbility {
onCreate(want: Want) {
console.info(`DistributedExtension ... |
application-dev\distributedservice\linkEnhance_development-guide.md | import {linkEnhance} from '@kit.DistributedServiceKit';
import { BusinessError } from '@kit.BasicServicesKit'; |
application-dev\distributedservice\linkEnhance_development-guide.md | {
"module" : {
"requestPermissions":[
{
"name" : "ohos.permission.DISTRIBUTED_DATASYNC",
"reason": "$string:distributed_permission",
"usedScene": {
"abilities": [
"MainAbility"
],
"when": "inuse"
}
... |
application-dev\distributedservice\linkEnhance_development-guide.md | const TAG = 'TEST';
// Register the service on the server.
linkEnhanceStart(name: string) {
console.info(TAG + 'start server deviceId = ' + name);
try {
// Construct a Server object using the service name.
let server: linkEnhance.Server = linkEnhance.createServer(name);
// Subsc... |
application-dev\distributedservice\linkEnhance_development-guide.md | serverAcceptOnCallback = (connection: linkEnhance.Connection): void => {
console.info(TAG + 'serverOnCallback');
try {
// Subscribe to disconnection events.
connection.on('disconnected', (number: number)=> {
console.info(TAG + 'disconnected, reason = ' + number);
});
... |
application-dev\distributedservice\linkEnhance_development-guide.md | // Disconnect from the peer end.
linkEnhanceDisconnect(connection: linkEnhance.Connection) {
console.info(TAG + 'disconnect deviceId = ' + connection.getPeerDeviceId());
try {
connection.disconnect();
connection.close();
} catch (err) {
console.error(TAG + 'disconnect errCo... |
application-dev\distributedservice\linkEnhance_development-guide.md | // Stop the service on the server.
linkEnhanceStop(server: linkEnhance.Server) {
console.info(TAG + 'stop server');
try {
server.stop();
} catch (err) {
console.info(TAG + 'stop server errCode: ' + (err as BusinessError).code + ', errMessage: ' +
(err as BusinessError).mess... |
application-dev\distributedservice\linkEnhance_development-guide.md | import linkEnhance from '@kit.DistributedServiceKit';
import { BusinessError } from '@kit.BasicServicesKit'; |
application-dev\distributedservice\linkEnhance_development-guide.md | {
"module" : {
"requestPermissions":[
{
"name" : "ohos.permission.DISTRIBUTED_DATASYNC",
"reason": "$string:distributed_permission",
"usedScene": {
"abilities": [
"MainAbility"
],
"when": "inuse"
}
... |
application-dev\distributedservice\linkEnhance_development-guide.md | const TAG = "testDemo";
// Connect to the server.
linkEnhanceConnect(peerDeviceId: string) {
console.info(TAG + 'connection server deviceId = ' + peerDeviceId);
try {
// Construct a Connection object by using peerDeviceId. The object is used for subsequent interactions.
let connectio... |
application-dev\distributedservice\linkEnhance_development-guide.md | disconnect(connection: linkEnhance.Connection) {
console.info(TAG + 'disconnect deviceId = ' + connection.getPeerDeviceId());
try {
connection.disconnect();
connection.close();
} catch (err) {
console.error(TAG + 'disconnect errCode: ' + (err as BusinessError).code + ', errMess... |
application-dev\enterprise-device-management\enterprise-extensionAbility.md | import EnterpriseAdminExtensionAbility from '@ohos.enterprise.EnterpriseAdminExtensionAbility';
export default class EnterpriseAdminAbility extends EnterpriseAdminExtensionAbility {
onAdminEnabled() {
console.info("onAdminEnabled");
}
onAdminDisabled() {
console.info("onAdminDisabled");
}
onBundl... |
application-dev\enterprise-device-management\enterprise-extensionAbility.md | import adminManager from '@ohos.enterprise.adminManager';
import Want from '@ohos.app.ability.Want';
import { BusinessError } from '@ohos.base';
async function subscribeManagedEventCallback() {
let admin: Want = {
bundleName: 'com.example.myapplication',
abilityName: 'EntryAbility',
}
adminManager.subscr... |
application-dev\faqs\faqs-arkts-utils.md | @Concurrent
function printArgs(args: number): number {
let t: number = Date.now();
while (Date.now() - t < 1000) { // 1000: delay 1s
continue;
}
console.info("printArgs: " + args);
return args;
}
let allCount = 100; // 100: test number
let taskArray: Array<taskpool.Task> = [];
// Create 300 tasks and add... |
application-dev\faqs\faqs-arkts-utils.md | class Task {
static run(args) {
// Do some independent task
}
}
let thread = new Thread(() => {
let result = Task.run(args)
// deal with result
}) |
application-dev\faqs\faqs-arkts-utils.md | import taskpool from '@ohos.taskpool'
@Concurrent
function run(args: string) {
// Do some independent task
}
let args: string = '';
let task = new taskpool.Task(run, args)
taskpool.execute(task).then((ret: string) => {
// Return result
}) |
application-dev\faqs\faqs-arkts-utils.md | class Material {
action(args) {
// Do some independent task
}
}
let material = new Material()
let thread = new Thread(() => {
let result = material.action(args)
// deal with result
}) |
application-dev\faqs\faqs-arkts-utils.md | import taskpool from '@ohos.taskpool'
@Concurrent
function runner(material: Material, args: string): void {
return material.action(args);
}
@Sendable
class Material {
action(args: string) {
// Do some independent task
}
}
let material = new Material()
taskpool.execute(runner, material).then((ret: string) => ... |
application-dev\faqs\faqs-arkts-utils.md | class Task {
run(args) {
// Do some independent task
task.result = true
}
}
let task = new Task()
let thread = new Thread(() => {
let result = task.run(args)
// deal with result
}) |
application-dev\faqs\faqs-arkts-utils.md | import taskpool from '@ohos.taskpool'
@Concurrent
function runner(task: Task) {
let args: string = '';
task.run(args);
}
@Sendable
class Task {
result: string = '';
run(args: string) {
// Do some independent task
return true;
}
}
let task = new Task();
taskpool.execute(runner, task).then((ret: strin... |
application-dev\faqs\faqs-arkts-utils.md | class Task {
run(args) {
// Do some independent task
runOnUiThread(() => {
UpdateUI(result)
})
}
}
let task = new Task()
let thread = new Thread(() => {
let result = task.run(args)
// deal with result
}) |
application-dev\faqs\faqs-arkts-utils.md | import taskpool from '@ohos.taskpool'
@Concurrent
function runner(task) {
task.run()
}
@Sendable
class Task {
run(args) {
// Do some independent task
taskpool.Task.sendData(result)
}
}
let task = new Task()
let run = new taskpool.Task(runner, task)
run.onReceiveData((result) => {
UpdateUI(result)
})
t... |
application-dev\faqs\faqs-arkts-utils.md | class SdkU3d {
static getInst() {
return SdkMgr.getInst();
}
getPropStr(str: string) {
return xx;
}
}
let thread = new Thread(() => {
// Game thread
let sdk = SdkU3d.getInst()
let ret = sdk.getPropStr("xx")
}) |
application-dev\faqs\faqs-arkts-utils.md | // Main thread
class SdkU3d {
static getInst() {
return SdkMgr.getInst();
}
getPropStr(str: string) {
}
}
const workerInstance = new
worker.ThreadWorker("xx/worker.ts");
let sdk = SdkU3d.getInst()
workerInstance.registerGlobalCallObject("instance_xx", sdk);
workerInstance.postMessage("start");
const mainP... |
application-dev\faqs\faqs-arkts-utils.md | // index.ets
let sab = new SharedArrayBuffer(32);
// int32 buffer view for sab
let i32a = new Int32Array(sab);
i32a[0] = 0;
let producer = new worker.ThreadWorker("entry/ets/workers/worker_producer.ts");
producer.postMessage(sab);
function consumection(e: MessageEvents) {
let sab: SharedArrayBuffer = e.data;
let ... |
application-dev\faqs\faqs-arkts-utils.md | class User {
age: number
constructor(age: number) {
this.age = age
}
}
// Declaration
function test(param: User): number;
function test(param: number, flag: boolean): number;
// Implementation
function test(param: User | number, flag?: boolean) {
if (typeof param === 'number') {
return param + (flag... |
application-dev\faqs\faqs-arkts-utils.md | / / src/main/ets/utils/Calc.ets of harlibrary
export class Calc {
public constructor() {}
public static staticAdd(a: number, b: number): number {
let c = a + b;
console.log("DynamicImport I'm harLibrary in staticAdd, %d + %d = %d", a, b, c);
return c;
}
public instanceAdd(a: number, b: number): numb... |
application-dev\faqs\faqs-arkui-animation-interactive-event.md | // Record the dragged item when the dragging is started.
.onDragStart((event?: DragEvent, extraParams?: string) => {
this.dragIndex = Number(item.data)
this.dragItem = item
})
// Execute the space filling animation when the dragged item enters a valid drop target.
.onDragEnter((event?: DragEvent, extraP... |
application-dev\faqs\faqs-arkui-arkts.md | @Entry
@Component
struct text {
build() {
Column(){
Text("\u{1F468}\u200D\u{1F468}\u200D\u{1F467}\u200D\u{1F466}")
.width(100)
.height(100)
.fontSize(50)
}
}
} |
application-dev\faqs\faqs-arkui-component.md | @Prop @Watch('onCountUpdated') count: number = 0;
@State total: number = 0;
// @Watch callback
onCountUpdated(propName: string): void {
this.total += this.count;
} |
application-dev\faqs\faqs-arkui-layout.md | Flex(){
Column().height('30%').width('30%').backgroundColor(Color.Blue)
.pixelRound({end: PixelRoundCalcPolicy.FORCE_CEIL})
Column().height('30%').width('30%').backgroundColor(Color.Blue)
Column().height('30%').width('30%').backgroundColor(Color.Blue)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.