Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
IT Security NachrichtenNew infosec products of the week: October 2, 2026(02.10.2026 um 06:00 Uhr)
•
IT Security NachrichtenERP-Migration: Kostenfalle Schnittstellen(02.10.2026 um 05:34 Uhr)
•
Android Tipps & SecurityAmazon reduziert eure Prime-Gebühr jetzt auf den alten Preis(02.10.2026 um 06:00 Uhr)
•••
Sicherheitslücken (CVE)CVE-2026-21140 | Samsung Devices access control (EUVD-2026-91157)(02.10.2026 um 05:08 Uhr)
••••
Sichere ProgrammierungWhat Can NSL Actually Do? — A Look at Nova Signal Language(02.10.2026 um 05:14 Uhr)
•
IT Security NachrichtenNew infosec products of the week: October 2, 2026(02.10.2026 um 06:00 Uhr)
•
IT Security NachrichtenERP-Migration: Kostenfalle Schnittstellen(02.10.2026 um 05:34 Uhr)
•
Android Tipps & SecurityAmazon reduziert eure Prime-Gebühr jetzt auf den alten Preis(02.10.2026 um 06:00 Uhr)
•••
Sicherheitslücken (CVE)CVE-2026-21140 | Samsung Devices access control (EUVD-2026-91157)(02.10.2026 um 05:08 Uhr)
••••
Sichere ProgrammierungWhat Can NSL Actually Do? — A Look at Nova Signal Language(02.10.2026 um 05:14 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

flutter_HarmonyOS Device Utility Librarynative_image

Harmony OS Next fluttertpc_device_util HarmonyOS Device Utility Library Flutter Code Implementation Create Method Channel static const MethodChannel _channel =…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!




Harmony OS Next






fluttertpc_device_util



HarmonyOS Device Utility Library






Flutter Code Implementation





  • Create Method Channel


    static const MethodChannel _channel = const MethodChannel('device_util');




  • Get Version Name


    /// The version name of this application
    static Future<String> get versionName async {
    final String version = await _channel.invokeMethod('getVersionName');
    return version;
    }




  • Get Version Code


    /// The version code of this application
    static Future<String> get versionCode async {
    final String version = await _channel.invokeMethod('getVersionCode');
    return version;
    }




  • Open Network Settings Page


    /// Open the device's network settings page
    static Future<Null> openNetworkSettingPage() async {
    await _channel.invokeMethod('launchNoNetwork');
    }




  • Open Application Settings


    /// Open settings page for the current application
    static Future<Null> openApplicationSettingPage() async {
    await _channel.invokeMethod('systemSettingPage');
    }




  • Get Device Information


    static Future<Map<String, String>> get getChannelInfo async {
    final Map<String, String> channelInfo =
    Map<String, String>.from(await _channel.invokeMethod('getChannelInfo'));
    return channelInfo;
    }




  • Terminate Application


    /// Terminate current application process and exit
    static Future<Null> killApp() async {
    await _channel.invokeMethod('killApp');
    }








HarmonyOS Implementation Code






```typescript
export class Utils {
/**
* Get system version information
*
* @return System version
*/
public static getDeviceBuildInfo(): string {
return deviceInfo.osFullName;
}

/**
* Get application bundle information
*
* @return BundleInfo object
*/
public static getAppBundleInfo(): Promise<bundleManager.BundleInfo> {
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT;
return bundleManager.getBundleInfoForSelf(bundleFlags);
}

/**
* Get channel information
* (Hardcoded to Huawei AppGallery for HarmonyOS)
*
* @return Channel information map
*/
public static getChannelInfo(): Map<string, string> {
const channelInfo = new Map<string, string>();
channelInfo.set("first_install_channel", "Huawei AppGallery For Harmony");
channelInfo.set("current_install_channel", "Huawei AppGallery For Harmony");
return channelInfo;
}

/**
* Navigate to system settings
*
* @param uiAbility Current UIAbility context
*/
public static jumpToSettings(uiAbility: UIAbility | null): void {
if (!uiAbility) {
Log.i(TAG, "jumpToSettings context empty");
return;
}
let want: Want = {
bundleName: 'com.huawei.hmos.settings',
abilityName: 'com.huawei.hmos.settings.MainAbility',
};
uiAbility.context.startAbility(want).catch((err: BusinessError) => {
Log.e(TAG, "jumpToSettings error: " + err);
});
}

/**
* Navigate to Wi-Fi settings
*
* @param uiAbility Current UIAbility context
*/
public static jumpToWifiSettings(uiAbility: UIAbility | null): void {
if (!uiAbility) {
Log.i(TAG, "jumpToWifiSettings context empty");
return;
}
let want: Want = {
bundleName: 'com.huawei.hmos.settings',
abilityName: 'com.huawei.hmos.settings.MainAbility',
uri: 'wifi_entry'
};
uiAbility.context.startAbility(want).catch((err: BusinessError) => {
Log.e(TAG, "jumpToWifiSettings error: " + err);
});
}

/**
* Navigate to app marketplace
*
* @param uiAbility Current UIAbility context
*/
public static async jumpToMarket(uiAbility: UIAbility | null): Promise<void> {
if (!uiAbility) {
Log.i(TAG, "jumpToMarket context empty");
return;
}
try {
let bundleInfo: bundleManager.BundleInfo = await Utils.getAppBundleInfo();
let bundleName: string | undefined = bundleInfo?.name;
if (!bundleName) {
Log.e(TAG, "jumpToMarket: get bundle name failed");
return;
}
let want: Want = {
parameters: { bundleName: bundleName }
};
productViewManager.loadProduct(uiAbility.context, want, {
onError: (error: BusinessError) => {
Log.e(TAG, "jumpToMarket error: " + error);
}
});
} catch (error) {
Log.e(TAG, "jumpToMarket exception: " + error);
}
}

/**
* Terminate application process
*/
public static killApp(): void {
Log.i(TAG, "Terminating application");
let pro = new process.ProcessManager();
pro.exit(0);
}
}
```


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten flutter_HarmonyOS Device Utility Librarynative_image

Thematisch verwandte Begriffe: flutterHarmonyOS, Device, Utility, Librarynativeimage · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag