protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.sample_chooser_activity); sampleAdapter = new SampleAdapter(this); ExpandableListView sampleListView = (ExpandableListView)FindViewById(Resource.Id.sample_list); sampleListView.SetAdapter(sampleAdapter); sampleListView.SetOnChildClickListener(this); Intent intent = Intent; string dataUri = intent.DataString; string[] uris; if (dataUri != null) { uris = new string[] { dataUri }; } else { List <string> uriList = new List <string>(); AssetManager assetManager = Assets; try { foreach (string asset in assetManager.List("")) { if (asset.EndsWith(".exolist.json")) { uriList.Add("asset:///" + asset); } } } catch (Java.IO.IOException e) { Toast.MakeText(ApplicationContext, Resource.String.sample_list_load_error, ToastLength.Long).Show(); } uriList.Sort(); uris = uriList.ToArray(); } downloadTracker = ((DemoApplication)Application).GetDownloadTracker(); SampleListLoader loaderTask = new SampleListLoader(this); loaderTask.Execute(uris); // Start the download service if it should be running but it's not currently. // Starting the service in the foreground causes notification flicker if there is no scheduled // action. Starting it in the background throws an exception if the app is in the background too // (e.g. if device screen is locked). try { Offline.DownloadService.Start(this, Java.Lang.Class.FromType(typeof(DemoDownloadService))); } catch (IllegalStateException e) { Offline.DownloadService.StartForeground(this, Java.Lang.Class.FromType(typeof(DemoDownloadService))); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.sample_chooser_activity); var intent = Intent; var dataUri = intent.DataString; string[] uris; if (dataUri != null) { uris = new string[] { dataUri }; } else { var uriList = new List <string>(); var assetManager = Assets; try { foreach (var asset in assetManager.List("")) { if (asset.EndsWith(".exolist.json", System.StringComparison.Ordinal)) { uriList.Add("asset:///" + asset); } } } catch (System.Exception) { Toast.MakeText(ApplicationContext, Resource.String.sample_list_load_error, ToastLength.Long) .Show(); } uriList.Sort(); uris = uriList.ToArray(); } var loaderTask = new SampleListLoader(this); loaderTask.Execute(uris); }