sicpaconnexions / SICPA_Connexions / Platforms / Android / MainActivity.cs @ 87e7d061
Historique | Voir | Annoter | Télécharger (2,079 ko)
1 |
using Android; |
---|---|
2 |
using Android.App; |
3 |
using Android.Content.PM; |
4 |
using Android.OS; |
5 |
using AndroidX.Core.App; |
6 |
|
7 |
namespace SICPA_Connexions |
8 |
{ |
9 |
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] |
10 |
public class MainActivity : MauiAppCompatActivity |
11 |
{ |
12 |
|
13 |
private static String[] PERMISSIONS_STORAGE = { |
14 |
Manifest.Permission.ReadExternalStorage, |
15 |
Manifest.Permission.WriteExternalStorage, |
16 |
Manifest.Permission.AccessFineLocation, |
17 |
Manifest.Permission.AccessCoarseLocation, |
18 |
Manifest.Permission.AccessLocationExtraCommands, |
19 |
Manifest.Permission.BluetoothScan, |
20 |
Manifest.Permission.BluetoothConnect, |
21 |
Manifest.Permission.BluetoothPrivileged |
22 |
}; |
23 |
|
24 |
private static String[] PERMISSIONS_BLUETOOTH = { |
25 |
Manifest.Permission.AccessFineLocation, |
26 |
Manifest.Permission.AccessCoarseLocation, |
27 |
Manifest.Permission.AccessLocationExtraCommands, |
28 |
Manifest.Permission.BluetoothScan, |
29 |
Manifest.Permission.BluetoothConnect, |
30 |
Manifest.Permission.BluetoothPrivileged |
31 |
}; |
32 |
|
33 |
protected override void OnCreate(Bundle savedInstanceState) |
34 |
{ |
35 |
base.OnCreate(savedInstanceState); |
36 |
Permission permission1 = ActivityCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage); |
37 |
Permission permission2 = ActivityCompat.CheckSelfPermission(this, Manifest.Permission.BluetoothScan); |
38 |
if (permission1 != Permission.Granted) |
39 |
{ |
40 |
// We don't have permission so prompt the user |
41 |
ActivityCompat.RequestPermissions(this, PERMISSIONS_STORAGE, 1); |
42 |
} else if (permission2 != Permission.Granted) |
43 |
{ |
44 |
ActivityCompat.RequestPermissions(this, PERMISSIONS_BLUETOOTH, 1); |
45 |
} |
46 |
} |
47 |
} |
48 |
} |