[Daily HarmonyOS Next Knowledge] Sandbox File Viewing, Long - running Tasks for VOIP, Log Length, etc.
1. How to view files in the HarmonyOS application sandbox?
Sandbox file viewing via IDE's Device File Browser (steps):
- Click View > Tool Windows > Device File Browser in the menu bar to open the Device File Browser.
- Select a connected device from the drop - down list.
- After selecting the device, the file/folder list will be displayed. You can:
- Right - click a directory or file to create/delete it.
- Right - click Save As to download the selected file or directory to the PC, or right - click Upload to upload a PC file to a specified directory on the device.
- To view a database file, download it (e.g., path:
data > app > el2 > 100 > database > project name > entry > rdb > database file
) to the PC and use other tools for visualization.
- To view a database file, download it (e.g., path:
- Type letters in the Device File Browser to search quickly.
- Double - click a file to open it in DevEco Studio. The file will be downloaded to a temporary directory (
%USER%\AppData\Local\Huawei\DevecoStudio{version}\device - file - browser\{device name}\{file path on device}
) and deleted after closing. - If you upload a file via the command line, right - click the corresponding folder and select Sync to display it in the Device File Browser.
2. For long - running tasks involving VOIP audio/video calls (only open to system apps), how do third - party VOIP apps (e.g., video conferencing software) apply for long - running tasks?
No need to apply for long - running tasks. Integrate with CallKit instead.
Reference document:
https://developer.huawei.com/consumer/cn/doc/harmonyos - guides - V5/call - introduction - V5
3. Why does creating an AVSessionManager fail when re - entering the app after a successful first creation?
Creation code:
let type: AVSessionManager.AVSessionType = 'audio';
let session = await AVSessionManager.createAVSession(this.context, 'AUDIO_NEWS', type);
// Activate the session after completing metadata and control command registration
await session.activate();
console.info(`session create done : sessionId : ${session.sessionId}`);
Reason: Only one media session can exist per UIAbility. Repeated creation fails. Check if the media session destruction method is called appropriately.
Related document:
https://developer.huawei.com/consumer/cn/doc/harmonyos - guides - V5/using - avsession - developer - V5
4. Why does the color displayed by createPixelMap differ from the expected color?
Code (expected blue, displayed red):
let length = 600 * 600 * 4;
let buffer = new Uint8Array(length);
for (let index = 0; index < length; ) {
buffer[index] = 0x00; // R
buffer[index + 1] = 0x00; // G
buffer[index + 2] = 0xff; // B
buffer[index + 3] = 0xff; // A
index = index + 4;
}
let opts: image.InitializationOptions = {
pixelFormat: image.PixelMapFormat.RGBA_8888,
size: {
height: 600,
width: 600
}
}
image.createPixelMap(buffer.buffer, opts).then((pixelMap) => {
this.context.drawImage(pixelMap, 0, 0);
})
Solution: The issue is due to swapped R and B channels. Manually swap R and B values to fix it.
5. Can the maximum length limit of 4096 bytes for HiLog be customized?
If exceeded, the log will be truncated. For long logs, it is recommended to split them into multiple segments for printing.
Top comments (0)