22using GeneralUpdate . Maui . Android . Models ;
33
44#if ANDROID
5- using Android . Content ;
6- using Android . OS ;
5+ using AndroidApp = Android . App ;
6+ using AndroidContent = Android . Content ;
7+ using AndroidNet = Android . Net ;
8+ using AndroidOS = Android . OS ;
79using AndroidX . Core . Content ;
8- using Java . IO ;
10+ using JavaFile = Java . IO . File ;
911#endif
1012
1113namespace GeneralUpdate . Maui . Android . Platform . Android ;
@@ -18,12 +20,12 @@ public sealed class AndroidApkInstaller : IApkInstaller
1820 public bool CanRequestPackageInstalls ( )
1921 {
2022#if ANDROID
21- if ( Build . VERSION . SdkInt < BuildVersionCodes . O )
23+ if ( AndroidOS . Build . VERSION . SdkInt < AndroidOS . BuildVersionCodes . O )
2224 {
2325 return true ;
2426 }
2527
26- var context = Android . App . Application . Context ;
28+ var context = AndroidApp . Application . Context ;
2729 return context . PackageManager ? . CanRequestPackageInstalls ( ) ?? false ;
2830#else
2931 return false ;
@@ -54,29 +56,29 @@ public Task TriggerInstallAsync(string apkFilePath, AndroidInstallOptions option
5456
5557 if ( ! System . IO . File . Exists ( apkFilePath ) )
5658 {
57- throw new FileNotFoundException ( "APK file was not found." , apkFilePath ) ;
59+ throw new System . IO . FileNotFoundException ( "APK file was not found." , apkFilePath ) ;
5860 }
5961
6062 if ( ! CanRequestPackageInstalls ( ) )
6163 {
6264 throw new InvalidOperationException ( "App is not allowed to request package installs. Grant 'install unknown apps' permission in system settings." ) ;
6365 }
6466
65- var context = Android . App . Application . Context ;
66- var apkFile = new File ( apkFilePath ) ;
67+ var context = AndroidApp . Application . Context ;
68+ var apkFile = new JavaFile ( apkFilePath ) ;
6769
68- using var intent = new Intent ( Intent . ActionView ) ;
69- intent . AddFlags ( ActivityFlags . NewTask ) ;
70- intent . AddFlags ( ActivityFlags . GrantReadUriPermission ) ;
70+ using var intent = new AndroidContent . Intent ( AndroidContent . Intent . ActionView ) ;
71+ intent . AddFlags ( AndroidContent . ActivityFlags . NewTask ) ;
72+ intent . AddFlags ( AndroidContent . ActivityFlags . GrantReadUriPermission ) ;
7173
72- Android . Net . Uri apkUri ;
73- if ( Build . VERSION . SdkInt >= BuildVersionCodes . N )
74+ AndroidNet . Uri apkUri ;
75+ if ( AndroidOS . Build . VERSION . SdkInt >= AndroidOS . BuildVersionCodes . N )
7476 {
7577 apkUri = FileProvider . GetUriForFile ( context , options . FileProviderAuthority , apkFile ) ;
7678 }
7779 else
7880 {
79- apkUri = Uri . FromFile ( apkFile ) ;
81+ apkUri = AndroidNet . Uri . FromFile ( apkFile ) ;
8082 }
8183
8284 intent . SetDataAndType ( apkUri , options . MimeType ) ;
0 commit comments