Re: [mono-android] Nothing being passed back from a webservice
Hi, That's getting me a good bit further, but there is still something not quite right. The new code looks like this private string rTrack; public ListgetUpcomingRaces(string track) { Listf = new List(); rTrack = track; f = getUpcomingRacesCallBack(cb); return f; } private List getUpcomingRacesCallBack(Action> callback) { List f = new List(); if (checkForNetwork(true) != true) { f.Add("No network available"); callback(f); } else { List tableData = new List(); POHWS.webservice.Service1 Service3 = new POHWS.webservice.Service1(); try { Service3.BeginGetUpcomingRacesList(rTrack, delegate(IAsyncResult iar) { tableData = Service3.EndGetUpcomingRacesList(iar).ToList(); Android.App.Application.SynchronizationContext.Post(delegate { if (tableData.Count == 0) { tableData[0].PostTime = "No Upcoming Races Found within the next 7 days"; } else { for (int i = 0; i < tableData.Count; ++i) f.Add(tableData[i].PostTime); } callback(f); //return f; }, null); callback(f); }, null); } catch (Exception oe) { f.Add(oe.ToString()); callback(f); //return f; } } return f; } I have tried this code and it returns nothing (much as before). Now, if I change the 2nd method to a void, how can I then propogate List to return it to the caller? Thanks Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Nothing-being-passed-back-from-a-webservice-tp5529892p5531003.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
[mono-android] UI threading problem
Hi, This could possibly be down to my current state of needing sleep but then again, it could be something else. I've searched for examples on how to fix the problem below, but can't seem to find what I need and it's starting to drive me potty! Essentially, I have a race condition whereby the webservice is finishing way after return has been given to the UI, so the UI is not displaying anything at all. Here's the code. The webservice does actually get the correct data which is the pain of it all! The generateNewScreen method comes as a result of clicking some text on a ListView area (calling routine) private void generateNewScreen(int t) { string[] races = new string[] { }; View currentview = FindViewById(Resource.Id.relLayout); TextView text = FindViewById(Resource.Id.textTitle); ListView listView = FindViewById(Resource.Id.listView); ImageView image = FindViewById(Resource.Id.imgBack); image.Visibility = ViewStates.Visible; Console.WriteLine("t = {0}, addFactor = {1}", t, addFactor); switch (addFactor) { case 0: switch (t) { case 0: races = listviewInfo(Resource.Array.RaceTracks, Resource.Drawable.Back_RaceHorsePlace, Resource.String.Tracks); addFactor = 10; break; case 1: List race = new List(); currentview.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.Back_BobMoore)); text.Text = Resources.GetString(Resource.String.ComingSoon); webservice_user getRace = new webservice_user(); race = getRace.getUpcomingRaces("RP"); races = race.ToArray(); addFactor = 20; break; } if (t < 6 || t == 7) listView.Adapter = new ArrayAdapter(this, Resource.Layout.listview_layout, races); break; } (webservice) private string rTrack; public List getUpcomingRaces(string track) { List f = new List(); rTrack = track; getUpcomingRacesCallBack((list) => { f = list; }); return f; } private void getUpcomingRacesCallBack(Action> callback) { List f = new List(); if (checkForNetwork(true) != true) { f.Add("No network available"); callback(f); } else { List tableData = new List(); POHWS.webservice.Service1 Service3 = new POHWS.webservice.Service1(); try { Service3.BeginGetUpcomingRacesList(rTrack, delegate(IAsyncResult iar) { tableData = Service3.EndGetUpcomingRacesList(iar).ToList(); Android.App.Application.SynchronizationContext.Post(delegate { if (tableData.Count == 0) { f.Add("No Upcoming Races Found within the next 7 days"); callback(f); } else { for (int i = 0; i < tableData.Count; ++i) f.Add(tableData[i].PostTime); callback(f); } }, null); }, null); } catch (Exception oe) { f.Add(oe.ToString()); callback(f); } } } Is it possible
Re: [mono-android] messagebox for android
Hi, Try this 8--> public class modal : Activity { private bool mChoice = false; private bool mQuitModal = false; private IntPtr mMsgQueueNextMethod; private IntPtr mMsgTargetField; public modal() { } public void showAlertDialog(Context context, string info) { if (!prepareModal()) return; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetMessage(info); builder.SetCancelable(false); builder.SetPositiveButton("OK", (object o, Android.Content.DialogClickEventArgs e) => { this.mQuitModal = true; builder.Dispose(); // was dialog.dismiss() }); AlertDialog alert = builder.Create(); alert.Show(); doModal(); } public bool showConfirmDialog(Context context, string info) { if (!prepareModal()) return false; // reset choice mChoice = false; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.SetMessage(info); builder.SetCancelable(false); builder.SetPositiveButton("OK", (object o, Android.Content.DialogClickEventArgs e) => { this.mQuitModal = true; this.mChoice = true; builder.Dispose(); }); builder.SetNegativeButton("Cancel", (object o, Android.Content.DialogClickEventArgs e) => { mQuitModal = true; mChoice = false; builder.Dispose(); // probably wrong }); AlertDialog alert = builder.Create(); alert.Show(); doModal(); return mChoice; } private bool prepareModal() { using (var MessageQueue_Class = Java.Lang.Class.FromType(typeof(Android.OS.MessageQueue))) using (var Message_Class = Java.Lang.Class.FromType(typeof(Android.OS.Message))) { mMsgQueueNextMethod = JNIEnv.GetMethodID(MessageQueue_Class.Handle, "next", "()Landroid/os/Message;"); mMsgTargetField = JNIEnv.GetFieldID(Message_Class.Handle, "target", "Landroid/os/Handler;"); return true; } } private void doModal() { mQuitModal = false; // get message queue associated with main UI thread MessageQueue queue = Looper.MyQueue(); while (!mQuitModal) { // call queue.next(), might block Message msg = null; try { IntPtr _msg = JNIEnv.CallObjectMethod(queue.Handle, mMsgQueueNextMethod); if (_msg == IntPtr.Zero) return; using (msg = Java.Lang.Object.GetObject(_msg, JniHandleOwnership.TransferLocalRef)) { IntPtr _target = JNIEnv.GetObjectField(msg.Handle, mMsgTargetField); if (_target == IntPtr.Zero) { mQuitModal = true; return; } using (var target = Java.Lang.Object.GetObject(_target, JniHandleOwnership.TransferLocalRef)) { target.DispatchMessage(msg); msg.Recycle(); } } } catch (System.Exception e) { } } } } <--8 Modal dialogues aren't really something you find on Android, but where there is a will... PFJ -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/messagebox-for-android-tp5709956p5709972.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
Re: [mono-android] What's up with 4.2.3 debugging?
Hi, The debugger seems to timeout like crazy. I may have to drop back down to 4.2.1 as my current projects need me to be able to debug code quickly and the current version really isn't good at it. Can someone at xamarin look into this? Thanks Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/What-s-up-with-4-2-3-debugging-tp5710322p5710341.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
[mono-android] Returning back from an activity that calls a SetWebViewClient
Hi, Hi, I have a simple problem Activity A calls Activity B Activity B has a webview and looks like this SetContentView(Resource.Layout.webView); WebView webView = FindViewById(Resource.Id.webView1); webView.Settings.JavaScriptEnabled = true; webView.LoadUrl(url); webView.SetWebViewClient(new dealWithWebView()); In dealWithWebView(), I have this class dealWithWebView : WebViewClient { WebView webView; public override void OnPageFinished(WebView view, string url) { webView = view; Context c = webView.Context; // it goes away and does something // calls another method in the class which returns back here } } Problem is that I don't seem to be able to get it to return back from the WebViewClient and then from "B" return back to "A". How do I do this? Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Returning-back-from-an-activity-that-calls-a-SetWebViewClient-tp5710374.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
Re: [mono-android] Unable to deploy to a device with MD and Mountain Lion 10.8.1
Hi, Looks like Samsung have yet to update their drivers for 10.8... Oh well. Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Unable-to-deploy-to-a-device-with-MD-and-Mountain-Lion-10-8-1-tp5711846p5711847.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
Re: [mono-android] Being driven insane....
Hi, Jonathan Pryor-2 wrote > >> In the main tab constructor, I have >> >> Bundle b; >> b.PutSerializable("data", foo); >> intent.PutExtras(b); > > This is not what you think it is. Java.IO.ISerialzable != > System.Runtime.ISerializable. They have _completely_ different semantics, > not least is that you can't actually, properly, implement > Java.IO.ISerializable at this time, as it requires private Java methods > which can't be generated right now. > > In short, this won't work. > Ah (hears penny drop) >> I'm trying to find a simple way to pass a class between tabs and it's >> annoying me now! > > If all your tabs are in the same process, just use a `public static` field > or similar. > > If a tab will be in a different process, the easiest route is XML > serialization, or a ContentProvider. > Are there any code examples of these specific to Mono for Android? This is seriously annoying me now. I've used XML before now in another app which is easy enough to do, but does seem overkill. Looking on the docs for the ContentProvider, it seems to be best suited to apps sharing data rather than sharing within the app itself. Thanks for everything so far :) Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Being-driven-insane-tp5016975p5017159.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
Re: [mono-android] Being driven insane....
Hi, Re XML serialization... Typically, I would use (say) foo p = new p(); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType()); x.Serialize(Console.Out, p); Obviously, I can't use Console.Out, so where do I need to point it to (for example a temporary file or something like that)? Thanks Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Being-driven-insane-tp5016975p5017190.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
Re: [mono-android] Being driven insane....
Hi, Hmm, something is still not right. Are there any types which cannot be serialized for Android? Currently, I have this [Serializable()] public class common { public int p, a, w, pa; public double bodyWeight, tempBody, tempSurround; public double[,] correctionData = new double[3, 20]; public double[,] iterations = new double[3, 20]; public double c, b, cas; public string s; } and to serialize in the main tab creator [Activity(MainLauncher = true, Label = "@string/ApplicationName", Theme = "@android:style/Theme.NoTitleBar")] public class AndroidTimeOfDeath : TabActivity { protected override void OnCreate(Bundle bundle) { common data = new common(); base.OnCreate(bundle); SetContentView(Resource.Layout.Main); TabHost.TabSpec spec; Intent intent; intent = new Intent(this, typeof(TimeTemp)); intent.AddFlags(ActivityFlags.NewTask); XmlSerializer x = new XmlSerializer(data.GetType()); StringWriter o = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); x.Serialize(o, data); // etc } The Serialize crashes and burns with a System.ArgumentException I'm trying to figure out why this is happening and wonder if there are any types that cannot be serialized. From a search, in standard C# Arrays of ArrayList and certain generics can't be handled. Does Android add anything additional to these? I have changed the [Serializable] to [Serializable()] as well as commenting it out and that makes no difference. The data.GetType() I have also tried as typeof(common). Still crashes and burns. Thanks Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Being-driven-insane-tp5016975p5028935.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
[mono-android] Menus
Hi, Is there an example anywhere on how to create a menu for an application from the menu button? I can't seem to find one. Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Menus-tp5029246p5029246.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
[mono-android] Non-serializable types in Monodroid?
Hi, Simple question - other than types not serializable in standard C#, are there any other additional types which cannot be serialized in Monodroid? I'm trying to serialize a class (below) using the code below that, but it dies when I try to serialize the class. [Serializable] public class common { public int p, a, w, pa; public double bodyWeight, tempBody, tempSurround; public double[,] correctionData = new double[3, 20]; public double[,] iterations = new double[3, 20]; public double c, b, cas; public string s; } and to serialize [Activity(MainLauncher = true, Label = "@string/ApplicationName", Theme = "@android:style/Theme.NoTitleBar")] public class AndroidTimeOfDeath : TabActivity { protected override void OnCreate(Bundle bundle) { common data = new common(); base.OnCreate(bundle); SetContentView(Resource.Layout.Main); TabHost.TabSpec spec; Intent intent; intent = new Intent(this, typeof(TimeTemp)); intent.AddFlags(ActivityFlags.NewTask); XmlSerializer x = new XmlSerializer(data.GetType()); StringWriter o = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); x.Serialize(o, data); // etc } The Serialize crashes and burns with a System.ArgumentException The serializer code looks right, so I'm trying to see if there is something in the class being serialized that Monodroid objects to. Any help would be appreciated. Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Non-serializable-types-in-Monodroid-tp5029261p5029261.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
[mono-android] Deserialize from Intent.GetStringExtra issue
Hi, I'm slowly getting there (which is always good). Serializing my class and passing it to other classes seems to be working. Unfortunately at the other end, things aren't as good - I'm getting a null exception. common data; public void deserialize() { System.Xml.Serialization.XmlSerializer t = new System.Xml.Serialization.XmlSerializer(typeof(common)); StringReader reader = new StringReader(Intent.GetStringExtra("mydata")); data = (common)t.Deserialize(reader); } This should be enough to deserialize and assign to data. The serialize code looks like this common data = new common(); // XmlSerializer x = new XmlSerializer(typeof(common)); StringWriter o = new StringWriter(System.Globalization.CultureInfo.InvariantCulture); x.Serialize(o, data); intent.PutExtra("mydata", o.ToString()); I'm assuming that I've used PutExtra correctly and that "mydata" is the token I need to pull in the deserialize step. Help I'd like to see the back of this app now ;) Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Deserialize-from-Intent-GetStringExtra-issue-tp5032637p5032637.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid
Re: [mono-android] Deploy to device without going through store
Hi, milop wrote > > Thanks, Andrew. > > That installs my app, but it doesn't install the Mono runtimes. > > How do I get those installed? > > Mike > >From what I understand, the mono runtimes are statically linked to the executable Paul -- View this message in context: http://mono-for-android.1047100.n5.nabble.com/Deploy-to-device-without-going-through-store-tp5032378p5032646.html Sent from the Mono for Android mailing list archive at Nabble.com. ___ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid