Skip to content

Commit dad3082

Browse files
committed
Sample: Catch if user disabled the system-app download manager on Android
1 parent a5a2860 commit dad3082

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Sample/Droid/MainActivity.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,23 @@ protected override void OnCreate (Bundle savedInstanceState)
124124
}
125125
};
126126

127-
foo.StartDownloading(FindViewById<Switch>(Resource.Id.switch1).Checked);
127+
try {
128+
foo.StartDownloading(FindViewById<Switch>(Resource.Id.switch1).Checked);
129+
} catch (Java.Lang.IllegalArgumentException) {
130+
foo.File = null;
131+
button.Text = "Download crashed.";
132+
133+
try {
134+
//Open the specific App Info page:
135+
Intent intent = new Intent(Android.Provider.Settings.ActionApplicationDetailsSettings);
136+
intent.SetData(Android.Net.Uri.Parse("package:com.android.providers.downloads"));
137+
StartActivity(intent);
138+
} catch (ActivityNotFoundException) {
139+
//Open the generic Apps page:
140+
Intent intent = new Intent(Android.Provider.Settings.ActionManageApplicationsSettings);
141+
StartActivity(intent);
142+
}
143+
}
128144
};
129145
}
130146
}

0 commit comments

Comments
 (0)