How to get Sharing Details in App Designer

25 ビュー (過去 30 日間)
Maxi
Maxi 2021 年 2 月 1 日
回答済み: Brian 2024 年 11 月 19 日
Hello,
is there a method to get the sharing details of the App Designer into my code.
For example I want to display the version and name of the app somewhere in my GUI without programming it directly. So when I create a new version of my app I only have to change the information in the sharing details and it will be updated in my GUI automatically.
Thanks!
  8 件のコメント
Anna H.
Anna H. 2024 年 7 月 24 日
I also would like to show the version in the userinterface of my app and access it programatically
Jixiong Su
Jixiong Su 2024 年 8 月 8 日
me too

サインインしてコメントする。

採用された回答

Maxi
Maxi 2024 年 10 月 29 日
Hello everyone,
I finally have a solution to this problem! You can get the metadata of the app with the following functions.
mlappMetaDataReader = mlapp.internal.MLAPPMetadataReader("app_name");
fileInfo = mlappMetaDataReader.readMLAPPMetadata();
I will now use this procedure in the startup functions of my applications:
app_name = mfilename();
mlappMetaDataReader = mlapp.internal.MLAPPMetadataReader(app_name);
fileInfo = mlappMetaDataReader.readMLAPPMetadata();
  3 件のコメント
Francisco Sacchetti
Francisco Sacchetti 2024 年 11 月 12 日
Maxi Do you have some documentation about this aproach so I can try to find out why it does not work in matlab webapp?
Thank you for your help.
Regards,
Francisco
Maxi
Maxi 2024 年 11 月 13 日
Hallo Francisco,
Unfortunately, there is no "official" documentation of the class. When you type into your command window
doc mlapp.internal.MLAPPMetadataReader
you will not find many informations.
I don't know where your problem is coming from as I haven't worked with web applications before.

サインインしてコメントする。

その他の回答 (2 件)

Taylor
Taylor 2024 年 1 月 23 日
When you go to package the app there is a field for the version number.
When the app is installed, the user can view the version number by hovering over the app.
  4 件のコメント
Taylor
Taylor 2024 年 4 月 16 日
Adee
Adee 2024 年 6 月 18 日
@Taylor, it doesn't seem to work - the code you pointed to takes the version number from the executable file, not from the app designer metadata.
The information in "Sharing details" is not propagated to the execuable file by the Matlab compiler. The version number can be specified using the "-W" switch but it still poses the problem of how to get the right number from the mlapp file...
Also, these details should preferably be available when running the app under MATLAB (before it is deployed).

サインインしてコメントする。


Brian
Brian 2024 年 11 月 19 日
The below function is what I use to detect the application version and compile date from within an application. This uses the xml2struct function from the File Exchange (https://www.mathworks.com/matlabcentral/fileexchange/28518-xml2struct) to parse the installer file info.
function [ver,date] = CheckAppVersion
% This function examines the installer info to determine the version number
% and release date of an application
if isdeployed
[~, result] = system('path');
p = char(regexpi(result, 'Path=(.*?);', 'tokens', 'once'));
xmlLocation=fullfile(p,'..','uninstall','ApplicationInstallerManifest.xml');
appInfo=xml2struct(xmlLocation);
ver=appInfo.ApplicationInstallerManifest.Version.Text;
file=dir(xmlLocation);
date=datetime(file.date);
date=char(datetime(date,'Format','dd-MMM-yyyy'));
else
fullpath=mfilename('fullpath');
s=settings;
if ~isempty(strfind(fullpath,s.matlab.addons.InstallationFolder.ActiveValue)) % If run from app
[p,~]=fileparts(fullpath); psplit=strsplit(p,filesep);
p=strjoin(psplit(1:find(strcmp(psplit,'Apps'))+1),filesep);
if isfolder(fullfile(p,'resources'))
xmlLocation=fullfile(p,'resources','addons_core.xml');
appInfo=xml2struct(xmlLocation);
ver=appInfo.addonCore.version.Text;
file=dir(xmlLocation);
date=datetime(file.date);
date=char(datetime(date,'Format','dd-MMM-yyyy'));
else
ver='debug';
date='dd-MMM-yyyy';
end
else % If run from MATLAB mlapp file
ver='debug';
date='dd-MMM-yyyy';
end
end
end

カテゴリ

Help Center および File ExchangePackage and Share Apps についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by