/// <summary> /// 检查权限授权状态 /// </summary> internal virtual Permission CheckSelfPermission(Context context, string permission) { try { PackageInfo info = context.PackageManager.GetPackageInfo(context.PackageName, 0); var targetSdkVersion = info.ApplicationInfo.TargetSdkVersion; if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.M) { if (targetSdkVersion >= Android.OS.BuildVersionCodes.M) { return(ContextCompat.CheckSelfPermission(context, permission)); } else { return((Permission)PermissionChecker.CheckSelfPermission(context, permission)); } } } catch (PackageManager.NameNotFoundException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } return(ContextCompat.CheckSelfPermission(context, permission)); }
internal PackageId() { #if __ANDROID__ _packageInfo = Android.App.Application.Context.PackageManager.GetPackageInfo(Android.App.Application.Context.PackageName, PackageInfoFlags.MetaData); #elif TIZEN _info = Tizen.Applications.Application.Current.ApplicationInfo; #endif }
internal PackageId() { #if __ANDROID__ _packageInfo = Android.App.Application.Context.PackageManager.GetPackageInfo(Android.App.Application.Context.PackageName, PackageInfoFlags.MetaData); #elif __IOS__ #elif WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81 || WINDOWS_UWP _packageId = Windows.ApplicationModel.Package.Current.Id; #endif }
private string GetAPKVersion(string fullApkPath) { try { Android.Content.PM.PackageInfo info = _context.PackageManager.GetPackageArchiveInfo(fullApkPath, 0); return(info.VersionName); } catch (Exception ex) { Log.LogErr($"Exception trying to get version from APK '{fullApkPath}'", ex); throw; } }
public string GetBeatSaberVersion() { if (!IsBeatSaberInstalled) { return(null); } try { Android.Content.PM.PackageInfo pInfo = _context.PackageManager.GetPackageInfo("com.beatgames.beatsaber", 0); return(pInfo.VersionName); } catch (PackageManager.NameNotFoundException e) { Log.LogErr("The Beat Saber package could not be found!"); throw; } catch (Exception ex) { Log.LogErr("Exception trying to determine Beat Saber version", ex); throw; } }
private void GetManifestPermissions() { lock (this) { PackageInfo packageInfo = null; try { packageInfo = mContext.PackageManager.GetPackageInfo(mContext.PackageName, PackageInfoFlags.Permissions); } catch (PackageManager.NameNotFoundException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } if (packageInfo != null && packageInfo.RequestedPermissions != null) { foreach (string perm in packageInfo.RequestedPermissions) { mManifestPermissions.Add(perm); } } } }
private Package() { #if __ANDROID__ _packageInfo = Android.App.Application.Context.PackageManager.GetPackageInfo(Android.App.Application.Context.PackageName, PackageInfoFlags.MetaData); #elif __UNIFIED__ _mainBundle = NSBundle.MainBundle; #elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81 _package = Windows.ApplicationModel.Package.Current; #elif TIZEN _info = Tizen.Applications.Application.Current.ApplicationInfo; #endif }
/// <summary> /// Returns true if the LVL check is required. /// </summary> /// <param name="pi"> /// the package info for the project /// </param> /// <returns> /// true if the filenames need to be returned /// </returns> private static bool IsLvlCheckRequired(PackageInfo pi) { // we need to update the LVL check and get a successful status to proceed return DownloadsDatabase.VersionCode != pi.VersionCode; }
/// <summary> /// The on create. /// </summary> public override void OnCreate() { base.OnCreate(); try { this.packageInfo = this.PackageManager.GetPackageInfo(this.PackageName, 0); string applicationLabel = this.PackageManager.GetApplicationLabel(this.ApplicationInfo); this.downloadNotification = new DownloadNotification(this, applicationLabel); } catch (PackageManager.NameNotFoundException e) { Log.Error(Tag, e, "Oh oh!"); } }
public AppInfoService (IContextService contextService) { _context = (Context) contextService.GetContext(); _packageInfo = _context.PackageManager.GetPackageInfo (_context.PackageName, 0); }
public AndroidPlatformHelper(Context context) { pInfo = context.PackageManager.GetPackageInfo(context.PackageName,PackageInfoFlags.Activities); }