maix::app

maix.app module

This is maix::app module of MaixCDK.
All of these elements are in namespace maix::app.

For MaixCDK developer: DO NOT edit this doc file manually, this doc is auto generated!

Module

No module

Enum

Variable

Function

app_id

Get current APP ID.

item description
return APP ID.

C++ defination code:

string app_id()

set_app_id

Set current APP ID.

item description
param app_id: APP ID.

C++ defination code:

string set_app_id(const string &app_id)

get_apps_info_path

Get APP info file path.

C++ defination code:

string get_apps_info_path()

get_apps_info

Get APP info list.

item description
param ignore_launcher: if true, ignore launcher APP. default false.
ignore_app_store: if true, ignore app store APP. default false.
return APP info list. APP_Info object list.

C++ defination code:

vector<app::APP_Info> &get_apps_info(bool ignore_launcher = false, bool ignore_app_store = false)

get_app_info

Get app info by app id.

item description
return app.APP_Info type.

C++ defination code:

app::APP_Info get_app_info(const std::string &app_id)

get_app_data_path

Get APP info, APP can store private data in this directory.

item description
return APP data path "./data", just return the data folder in current path because APP executed in app install path or project path.
So, you must execute your program in you project path to use the project/data folder when you debug your APP.

C++ defination code:

string get_app_data_path()

get_app_path

Get APP path.

item description
param app_id: APP ID, if empty, return current APP path, else return the APP path by app_id.
return APP path, just return the current path because APP executed in app install path or project path.
So, you must execute your program in you project path to use the project/data folder when you debug your APP.

C++ defination code:

string get_app_path(const string &app_id = "")

get_tmp_path

Get global temporary data path, APPs can use this path as temporary data directory.

item description
return temporary data path.

C++ defination code:

string get_tmp_path()

get_share_path

Get data path of share, shared data like picture and video will put in this directory

item description
return share data path.

C++ defination code:

string get_share_path()

get_picture_path

Get picture path of share, shared picture will put in this directory

item description
return share picture path.

C++ defination code:

string get_picture_path()

get_video_path

Get video path of share, shared video will put in this directory

item description
return share video path.

C++ defination code:

string get_video_path()

get_font_path

Get font path of share, shared font will put in this directory

item description
return share font path.

C++ defination code:

string get_font_path()

get_icon_path

Get icon path of share, shared icon will put in this directory

item description
return share icon path.

C++ defination code:

string get_icon_path()

get_sys_config_kv

Get system config item value.

item description
param item: name of setting item, e.g. wifi, language. more see settings APP.
key: config key, e.g. for wifi, key can be ssid, for language, key can be locale.
value: default value, if not found, return this value.
from_cache: if true, read from cache, if false, read from file.
return config value, always string type, if not found, return empty string.

C++ defination code:

string get_sys_config_kv(const string &item, const string &key, const string &value = "", bool from_cache = true)

get_app_config_kv

Get APP config item value.

item description
param item: name of setting item, e.g. user_info
key: config key, e.g. for user_info, key can be name, age etc.
value: default value, if not found, return this value.
from_cache: if true, read from cache, if false, read from file.
return config value, always string type, if not found, return empty string.

C++ defination code:

string get_app_config_kv(const string &item, const string &key, const string &value = "", bool from_cache = true)

set_app_config_kv

Set APP config item value.

item description
param item: name of setting item, e.g. user_info
key: config key, e.g. for user_info, key can be name, age etc.
value: config value, always string type.
write_file: if true, write to file, if false, just write to cache.
return err::Err

C++ defination code:

err::Err set_app_config_kv(const string &item, const string &key, const string &value, bool write_file = true)

get_app_config_path

Get APP config path, ini format, so you can use your own ini parser to parse it like configparser in Python.\nAll APP config info is recommended to store in this file.

item description
return APP config path(ini format).

C++ defination code:

string get_app_config_path()

set_exit_msg

Set APP exit code and exit message.\nIf code != 0, the launcher will show a dialog to user, and display the msg.

item description
param code: exit code, 0 means success, other means error, if code is 0, do nothing.
msg: exit message, if code is 0, msg is not used.
return exit code, the same as arg @code.

C++ defination code:

err::Err set_exit_msg(err::Err code, const string &msg)

get_exit_msg

Get APP exit code and exit message.

item description
param cache: if true, read from cache, if false, read from file. default false.
return exit return app_id, exit code and exit message.

C++ defination code:

tuple<string, err::Err, string> get_exit_msg(bool cache = false)

have_exit_msg

Check if have exit msg

item description
param cache: if true, just check from cache, if false, check from file. default false.
return true if have exit msg, false if not.

C++ defination code:

bool have_exit_msg(bool cache = false)

switch_app

Exit this APP and start another APP(by launcher).\nCall this API will call set_exit_flag(true), you should check app::need_exit() in your code.\nAnd exit this APP if app::need_exit() return true.

item description
param app_id: APP ID which will be started. app_id and idx must have one is valid.
idx: APP index. app_id and idx must have one is valid.
start_param: string type, will send to app, app can get this param by app.get_start_param()
attention If app id or idx the same as current app, do nothing.

C++ defination code:

void switch_app(const string &app_id, int idx = -1, const std::string &start_param = "")

get_start_param

Get start param set by caller

item description
return param, string type

C++ defination code:

const std::string get_start_param()

need_exit

Shoule this APP exit?

item description
return true if this APP should exit, false if not.
attention This API is a function, not a variable.

C++ defination code:

bool need_exit()

running

App should running? The same as !app::need_exit() (not app::need_exit() in MaixPy).

item description
return true if this APP should running, false if not.
attention This API is a function, not a variable.

C++ defination code:

bool running()

set_exit_flag

Set exit flag. You can get exit flag by app.need_exit().

item description
param exit: true if this APP should exit, false if not.

C++ defination code:

void set_exit_flag(bool exit)

Class

Version

APP version

C++ defination code:

class Version

__str__

Convert to string, e.g. 1.0.0

item description
type func
static False

C++ defination code:

std::string __str__()

from_str

Convert from string, e.g. "1.0.0"

item description
type func
static True

C++ defination code:

static app::Version from_str(const string &version_str)

APP_Info

APP info

C++ defination code:

class APP_Info

id

APP id

item description
type var
static False
readonly False

C++ defination code:

string id

name

APP name

item description
type var
static False
readonly False

C++ defination code:

string name

icon

APP icon

item description
type var
static False
readonly False

C++ defination code:

string icon

version

APP version

item description
type var
static False
readonly False

C++ defination code:

Version version

exec

APP exec

item description
type var
static False
readonly False

C++ defination code:

string exec

author

APP author

item description
type var
static False
readonly False

C++ defination code:

string author

desc

APP desc

item description
type var
static False
readonly False

C++ defination code:

string desc

names

APP names

item description
type var
static False
readonly False

C++ defination code:

map<string, string> names

descs

APP descs

item description
type var
static False
readonly False

C++ defination code:

map<string, string> descs