Skip to content

Commit

Permalink
Sample: Catch if user disabled the system-app download manager on And…
Browse files Browse the repository at this point in the history
…roid
  • Loading branch information
SimonSimCity committed Jun 4, 2018
1 parent a5a2860 commit dad3082
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Sample/Droid/MainActivity.cs
Expand Up @@ -124,7 +124,23 @@ protected override void OnCreate (Bundle savedInstanceState)
}
};

foo.StartDownloading(FindViewById<Switch>(Resource.Id.switch1).Checked);
try {
foo.StartDownloading(FindViewById<Switch>(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);
}
}
};
}
}
Expand Down

0 comments on commit dad3082

Please sign in to comment.