From dad3082365ef9161e982fdf1a4dba5f83c63c3ad Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Mon, 4 Jun 2018 15:23:12 +0400 Subject: [PATCH] Sample: Catch if user disabled the system-app download manager on Android --- Sample/Droid/MainActivity.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sample/Droid/MainActivity.cs b/Sample/Droid/MainActivity.cs index f5ba61d..09ac713 100644 --- a/Sample/Droid/MainActivity.cs +++ b/Sample/Droid/MainActivity.cs @@ -124,7 +124,23 @@ protected override void OnCreate (Bundle savedInstanceState) } }; - foo.StartDownloading(FindViewById(Resource.Id.switch1).Checked); + try { + foo.StartDownloading(FindViewById(Resource.Id.switch1).Checked); + } catch (Java.Lang.IllegalArgumentException) { + foo.File = null; + button.Text = "Download crashed."; + + try { + //Open the specific App Info page: + Intent intent = new Intent(Android.Provider.Settings.ActionApplicationDetailsSettings); + intent.SetData(Android.Net.Uri.Parse("package:com.android.providers.downloads")); + StartActivity(intent); + } catch (ActivityNotFoundException) { + //Open the generic Apps page: + Intent intent = new Intent(Android.Provider.Settings.ActionManageApplicationsSettings); + StartActivity(intent); + } + } }; } }