在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
有个需求,想判断手机里是否安装指定的app,没找到现成的代码,参考Delphi代码实现了一个,当返回空串时,表示没有安装app。 function GetVersionString(APackageName:string): string; //uses Androidapi.JNI.GraphicsContentViewText,Androidapi.Helpers,androidapi.jni.javatypes; var PackageInfo: JPackageInfo; PackageManager: JPackageManager; AppContext: JContext; begin AppContext := TAndroidHelper.Context; if AppContext <> nil then begin PackageManager := AppContext.getPackageManager; if PackageManager <> nil then begin try PackageInfo := AppContext.getPackageManager.getPackageInfo(StringToJString(APackageName), 0); except Exit(string.Empty); end; if PackageInfo <> nil then Exit(JStringToString(PackageInfo.versionName)); end; end; Result := string.Empty; end; 调用代码: if GetVersionString('com.kinglandsoft.xmyt')='' then begin //没有安装app ... end
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论