コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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()));
        }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
        /// <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);
        }
コード例 #7
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);
        }