It is not something I do often but every now and then I need to send or receive a fax. I generally search services online and look at different mobile apps. On occasion I have also opted to visit the nearest UPS or FedEx store. The problem I find with online services is that most require a subscription, free ones add their information on the cover page and most mobile apps require credits in the form of in-app purchases. There’s definitely nothing wrong with either of these avenues but I thought how cool it would be to simply write my own. I remembered Twilio has a fax API that is still in beta and decided to code my own. In this post I’ll describe how to build a simple console app to send/receive faxes. …


Hello Coders,

I have updated dannycabrera.GetiOSModel to version 1.6 with Apple’s new iPad models: iPad Pro 12.9-inch (3rd generation) and iPad Pro 11-inch. Both of these new iPad Pro versions include both WiFi and WiFi + Cellular models. This little library has taken off from just a few hundred total downloads to surpassing 56k this week. Hope it continues to be helpful for all Xamarin developers.


I have updated dannycabrera.GetiOSModel to v1.5.0 with Apple’s three new iPhone models, iPhone XR, iPhone Xs and iPhone Xs Max.


Happy Friday Everyone,

I pushed out version 1.2 of GetDroidModel that includes 1,880 devices changes since last update on 3/30/2018 bring the new device list to 20,550 Google Play Store supported devices.

GitHub: https://github.com/dannycabrera/GetDroidModel

Nuget: https://www.nuget.org/packages/dannycabrera.GetDroidModel

Device changes:


Sometimes you need to present the user with data and wait for a response all while not lock up the UI thread. Microsoft’s asynchronous programming model our best friend and in just a few lines we can wait for a response from DialogBuilder. In this code example we’ll wait for AlertDialog’s positive or negative button being tapped.

This AlertAsync method uses the TaskCompletionSource<TResult> type to create the task and handle the completion. Upon the user tapping the positive or negative button we call TrySetResult() on the TaskCompletionSource to return our bool value.

Image for post
Image for post
AlertDialog

Happy Coding!


When recording (low level) PCM encoded audio in Android with AudioRecord, the application must continuously read the audio buffer and write the raw data to an audio file. One of downsides to using AudioRecord is that only raw uncompressed data is returned, meaning it’s missing the header which can only be created once the recording has completed. The application must create a WAVE header in order to play/stream outside of Android. AudioTrack will play the file just fine without a header but any another player won’t know what to do with it.

Creating header:

Image for post
Image for post
Image From: http://soundfile.sapp.org/doc/WaveFormat/

To create the header we first need to know what it needs to contain and exactly where. The diagram above displays the fields needed in the 44 bytes long header. I created a simple method WriteWavHeader(string filePath, int sampleRate, short bitsPerSample, short channels) to write the header, just supply the path to the audio file, sample rate, bitsPerSample and # of channels. The method takes care of opening the file, seeks to the beginning and writes the 44 bytes to complete our WAV file. The method uses BitConverter to write the bytes array to the header taking care of endianness. …


There are various options out there to create zip files in your Xamarin projects and an issue with a 3rd party library gave me the opportunity to seek an alternative. The problem I often run into when relying on a 3rd party and/or open source code is compatibility and in some cases support when running into a bug. On Xamarin.iOS I remember having issues with compatibility and an odd bug likely related to memory consumption. Working on a Xamarin.Android project I didn’t want to rely on native java so I could share code cross-platform and looked for a .NET solution. Microsoft introduced the ZipArchive library in .NET 4.5 …


If you are ever working on a Xamarin.Android App and need to dismiss an AlertDialog box when loading SingleChoiceItems here’s an easy way to achieve it.

In the example below we create a new DialogBuilder instance, adding a title and then loading several items as SingleChoiceItems. Then on the DialogClickEventArgs handler grab a reference to the AlertDialog var d; and simply call d.Dismiss() to dismiss dialog, removing it from the screen.


Found myself in need of moving an item stored in an IList to the top of the stack. Some IList methods like RemoveAt() and Insert() would work however wouldn’t be as efficient with a large data set. Fortunately found a Stack Overflow post which would do the move in a single step. I renamed the extension to MoveToTop and here’s a quick and easy Xamarin Workbook sample.

Output:

Id: 3 Name: Third
Id: 1 Name: First
Id: 2 Name: Second

Hope someone finds this useful. Feel free to share/like etc.


Some years ago I wrote a handy library Get iOS Model that I open-sourced on Github and through the years I’ve been asked if I would ever create an Xamarin.Android version. Finally got around to it and made it available this week.

The package consists of 18,554 Android devices that support Google Play which I will update regularly.

Using the package is pretty simple:

  1. Install the nuget package dannycabrera.GetDroidModel
  2. Make a call to:
GetDroidModel.DeviceHardware.Model();

Example: Device model “SM-G960F” will return as “Galaxy S9”.

If you prefer having the manufacturer’s name returned call:

GetDroidModel.DeviceHardware.Model(defaultValue: “Unknown”, includeManufacturer: true);

Example: Device model “SM-G960F” will return as “Samsung Galaxy S9”.

Hope this is a useful library/plugin for all.

About

Danny Cabrera

Principal Software Engineer at Command Health https://github.com/dannycabrera

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store