xamarin.android

Why IAsyncResult report all port as opened?

走远了吗. 提交于 2019-12-19 10:54:35
问题 i have this method running in a thread , but when i test it report all ports as open. it seems that the method : var result = client.BeginConnect(host, port, null, null); don't working well when passing the results in var success = result.AsyncWaitHandle.WaitOne(tcpTimeout); ... Any idea how to solve that ? I have tried client.ConnectAsync(host,port).Wait(TcpTimeout); but this is not working as expected too .... public void start() { Thread thread1 = new Thread(new ThreadStart(RunScanTcp));

Xamarin.Android mvvmcross app crashes when launching with intent filter

只谈情不闲聊 提交于 2019-12-19 10:48:09
问题 When opening up the android application via a link, the android application crashes, with a NullReferenceExcetpion . The NRE happens in the base.OnCreate(bundle) method. The base is of type MvxFragmentCompatActivity . I have also tried this with a standard MvxActivity . I have had a look at the following questions (but to no avail) ViewModel null when Activity started from IntentFilter Open MvvmCross app via link with data The Activity [Activity(...)] [IntentFilter(new[] { Intent.ActionView }

Algorithm to vertically flip a bitmap in a byte array

。_饼干妹妹 提交于 2019-12-19 10:37:06
问题 I am writing a class for printing bitmaps to a portable bluetooth printer in Android via Mono For Android. My class is used to obtain the pixel data from the stream so that is can be sent to the printer in the correct format. Right now the class is simple, it just reads the height, width, and bits per pixel. Using the offset it reads and returns the pixel data to the printer. Right now I am just working with 1 bit per pixel black and white images. The bitmaps I am working with are in Windows

ListView not unselecting

无人久伴 提交于 2019-12-19 10:30:28
问题 I am working on a Xamarin.Forms project with a ListView. The XAML for the ListView is <render:CustomListView x:Name="listview" ItemSelected="ItemSelected" ItemTapped="ItemTapped"></render:CustomListView> And the C# is public void ItemTapped(object sender, ItemTappedEventArgs e) { var Selected = e.Item as Classes.NavigationItem; //Handle clicked } ((ListView)sender).SelectedItem = null; } private void ItemSelected(object sender, SelectedItemChangedEventArgs e) { ((ListView)sender).SelectedItem

UDP from AndroidEmulator (--Genymotion--) to localhost Server(10.0.2.2) does not work?

烈酒焚心 提交于 2019-12-19 10:19:19
问题 I simply try to send and receive data between MonodroidApp(AndroidEmulator) and a localDevServer. I understand localhost is specially mapped to "10.0.2.2" on AndroidEmulator, so I did the following, but the app does not respond. System.Text.Encoding enc = System.Text.Encoding.UTF8; string sendMsg = "testtest"; byte[] sendBytes = enc.GetBytes(sendMsg); int localPort = 39000; var udp = new System.Net.Sockets.UdpClient(localPort); //send data string remoteHost = "10.0.2.2";//"127.0.0.1"; int

Creating an extension of WebView in Xamarin.Froms to display gifs. I cannot load the image on Android

懵懂的女人 提交于 2019-12-19 10:14:56
问题 iOS works as expected. I have tried adding the .gif to the assets folder too (setting the BaseUrl to "file:///android_asset") with no luck. Any ideas? imageHtml = "<center><body bgcolor =\"" + GetBackgroundColorHex() + "\"" + heightAndWidth + ">" + (!string.IsNullOrWhiteSpace(imageFileName) ? "<img src=\"" + imageFileName + "\"" + heightAndWidth + "/>" : " ") + "</body></center>"; HtmlWebViewSource source = new HtmlWebViewSource() { Html = imageHtml }; if (Device.RuntimePlatform == Device

Prevent EditText from automatically focusing

元气小坏坏 提交于 2019-12-19 10:04:25
问题 I have an Android activity and there is one EditText in the whole layout. For some reason, whenever the activity starts, the keyboard comes up. I have tried all of the following things: Placing these two in OnStart : FindViewById<EditText> (Resource.Id.searchText).ClearFocus (); FindViewById<EditText> (Resource.Id.searchText).Selected = false; Adding a LinearLayout with these two properties: android:focusable="true" android:focusableInTouchMode="true" Adding the following tag inside another

Prexisiting dlls (.NET 4 framework) issue with mono for android

痞子三分冷 提交于 2019-12-19 08:14:49
问题 I am creating a fresh Mono for android application using http://xamarin.com/monoforandroid I selected Mono for Android Application using Visual C# option. My Android target version is : I went to references of the project and tried adding my pre existing dlls (made in .NET 4 Framework) and I got this error: The strange stuff is there is no option to change the .NET Framework from project properties. Can you tell me what I am missing? 回答1: The problem here is that you're trying to reference a

Spinner OnItemSelectedListener

大城市里の小女人 提交于 2019-12-19 07:29:07
问题 I can't find an example of how to do this in mono. Any help? Edit: Added code foreach (equip item in list) { tr = new TableRow(this); sp = new Spinner(this); sp.LayoutParameters = lp2; sp.Adapter = adapter; sp.ItemSelected += new EventHandler<ItemEventArgs>(spinner_ItemSelected()); sp.SetSelection(Convert.ToInt32(item.status)); tr.AddView(sp); } private void spinner_ItemSelected(object sender, ItemEventArgs e) { Spinner spinner = (Spinner)sender; string toast = string.Format ("You selected {0

How to grant permission to open usb device with usb manager? openDevice() always returns null

江枫思渺然 提交于 2019-12-19 03:19:45
问题 I want to use a usb device in the following code. It successfully lists the usb devices and iterates over them. In the following code the object "device" is the usbdevice that i need to open. Everything seems Ok except the OpenDevice() method that always returns a null value ! [Activity(Label = "TestApp", MainLauncher = true, Icon = "@drawable/icon")] [IntentFilter(new[] {UsbManager.ActionUsbDeviceAttached})] [MetaData(UsbManager.ActionUsbDeviceAttached, Resource = "@xml/device_filter")]