Skip to content

Commit

Permalink
Xamarin: fix android 13 startup
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Jan 15, 2024
1 parent 1edc52a commit a67d45c
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions ExtLibs/Xamarin/Xamarin.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ namespace Xamarin.Droid
{ //global::Android.Content.Intent.CategoryLauncher
//global::Android.Content.Intent.CategoryHome,
[IntentFilter(new[] { global::Android.Content.Intent.ActionMain, global::Android.Content.Intent.ActionAirplaneModeChanged ,
global::Android.Content.Intent.ActionBootCompleted , UsbManager.ActionUsbDeviceAttached, UsbManager.ActionUsbDeviceDetached,
global::Android.Bluetooth.BluetoothDevice.ActionFound, global::Android.Bluetooth.BluetoothDevice.ActionAclConnected, UsbManager.ActionUsbAccessoryAttached},
Categories = new []{ global::Android.Content.Intent.CategoryLauncher})]
global::Android.Content.Intent.ActionBootCompleted , UsbManager.ActionUsbDeviceAttached, UsbManager.ActionUsbDeviceDetached,
global::Android.Bluetooth.BluetoothDevice.ActionFound, global::Android.Bluetooth.BluetoothDevice.ActionAclConnected, UsbManager.ActionUsbAccessoryAttached},
Categories = new[] { global::Android.Content.Intent.CategoryLauncher })]
[IntentFilter(actions: new[] { global::Android.Content.Intent.ActionView }, Categories = new[] { global::Android.Content.Intent.CategoryBrowsable, global::Android.Content.Intent.ActionDefault, global::Android.Content.Intent.CategoryOpenable }, DataHost = "*", DataPathPattern = ".*\\.tlog", DataMimeType = "*/*", DataSchemes = new[] { "file", "http", "https", "content" })]
[IntentFilter(actions: new[] { global::Android.Content.Intent.ActionView }, Categories = new[] { global::Android.Content.Intent.CategoryBrowsable, global::Android.Content.Intent.ActionDefault, global::Android.Content.Intent.CategoryOpenable }, DataHost = "*", DataPathPattern = ".*\\.bin", DataMimeType = "*/*", DataSchemes = new[] { "file", "http", "https", "content" })]
[IntentFilter(actions: new[] { global::Android.Content.Intent.ActionView }, Categories = new[] { global::Android.Content.Intent.CategoryBrowsable, global::Android.Content.Intent.ActionDefault, global::Android.Content.Intent.CategoryOpenable }, DataHost = "*", DataPathPattern = ".*\\.bin", DataMimeType = "*/*", DataSchemes = new[] { "file", "http", "https", "content" })]
[MetaData("android.hardware.usb.action.USB_DEVICE_ATTACHED", Resource = "@xml/device_filter")]
[Activity(Label = "Mission Planner", Exported = true, ScreenOrientation = ScreenOrientation.SensorLandscape, Icon = "@mipmap/icon", Theme = "@style/MainTheme",
[Activity(Label = "Mission Planner", Exported = true, ScreenOrientation = ScreenOrientation.SensorLandscape, Icon = "@mipmap/icon", Theme = "@style/MainTheme",
MainLauncher = true, HardwareAccelerated = true, DirectBootAware = true, Immersive = true, LaunchMode = LaunchMode.SingleInstance)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
Expand Down Expand Up @@ -141,7 +141,7 @@ protected override void OnActivityResult(int requestCode, Result resultCode, Int
var query = this.ContentResolver.Query(docUriTree, null, null,
null, null);
query.MoveToFirst();
var filePath = query.GetString(0);
var filePath = query.GetString(0);
query.Close();

pref.Edit().PutString("Directory", filePath).Commit();
Expand Down Expand Up @@ -173,7 +173,7 @@ protected override void OnCreate(Bundle savedInstanceState)
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;

SetSupportActionBar((Toolbar) FindViewById(ToolbarResource));
SetSupportActionBar((Toolbar)FindViewById(ToolbarResource));

this.Window.AddFlags(WindowManagerFlags.Fullscreen | WindowManagerFlags.TurnScreenOn |
WindowManagerFlags.HardwareAccelerated);
Expand Down Expand Up @@ -304,11 +304,11 @@ void ContinueInit()

{
if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) !=
(int) Permission.Granted ||
(int)Permission.Granted ||
ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) !=
(int) Permission.Granted ||
(int)Permission.Granted ||
ContextCompat.CheckSelfPermission(this, Manifest.Permission.Bluetooth) !=
(int) Permission.Granted)
(int)Permission.Granted)
{
ActivityCompat.RequestPermissions(this,
new String[]
Expand All @@ -318,15 +318,7 @@ void ContinueInit()
Manifest.Permission.Bluetooth
}, 1);
}

while (ContextCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) !=
(int) Permission.Granted)
{
Thread.Sleep(1000);
var text = "Checking Permissions - " + DateTime.Now.ToString("T");

//DoToastMessage(text);
}

}

try {
Expand Down

0 comments on commit a67d45c

Please sign in to comment.