public string GetVersion() { var context = global::Android.App.Application.Context; Android.Content.PM.PackageManager manager = context.PackageManager; Android.Content.PM.PackageInfo info = manager.GetPackageInfo(context.PackageName, 0); return(info.VersionName); }
public int GetBuild() { var context = global::Android.App.Application.Context; Android.Content.PM.PackageManager manager = context.PackageManager; Android.Content.PM.PackageInfo info = manager.GetPackageInfo(context.PackageName, 0); return(info.VersionCode); }
public string GetVersionString() { var context = global::Android.App.Application.Context; Android.Content.PM.PackageManager pm = context.PackageManager; Android.Content.PM.PackageInfo pinfo = pm.GetPackageInfo(context.PackageName, 0); return(pinfo.VersionName); }
public VersionInfo GetVersionAndBuildNumber() { Context context = global::Android.App.Application.Context; Android.Content.PM.PackageManager manager = context.PackageManager; Android.Content.PM.PackageInfo info = manager.GetPackageInfo(context.PackageName, 0); return(new VersionInfo(info.VersionName, info.VersionCode.ToString())); }
public bool PackageIsInstalledOnDevice(string packageName) { Android.Content.PM.PackageManager pm = MainActivity.Instance.ApplicationContext.PackageManager; try { pm.GetPackageInfo(packageName, Android.Content.PM.PackageInfoFlags.Activities); return(true); } catch { return(false); } }
/// <summary> /// 判断本机上是否有能处理当前Intent的Activity /// </summary> /// <returns></returns> protected bool DoesActivityExists() { if (!MainApplication.Initialized) { return(false); } var app = MainApplication.GetInstance(); Android.Content.PM.PackageManager pm = app.PackageManager; var list = pm.QueryIntentActivities(intent, Android.Content.PM.PackageInfoFlags.MatchDefaultOnly); return(list != null && list.Count() > 0); }
/// <summary> /// 判断相对应的APP是否存在 /// </summary> /// <param name="context"></param> /// <param name="packageName"></param> /// <returns></returns> bool isAvilible(Context context, string packageName) { Android.Content.PM.PackageManager packageManager = context.PackageManager; var pinfo = packageManager.GetInstalledPackages(Android.Content.PM.PackageInfoFlags.Activities); foreach (var item in pinfo) { if (item.PackageName.Equals(packageName, StringComparison.CurrentCultureIgnoreCase)) { return(true); } } return(false); }