Today I Learned How to Handle Local Notifications in Xamarin on Android

In my previous example I detailed how to schedule notifications in Xamarin on Android but didn’t show the Xamarin Forms application reacting to that specific notification.  Let’s fix that.

First override the OnNewIntent method in the MainActivity.  We override this method so notifications will work if the application is currently running or is stopped and the notification started the application.  In the OnNewIntent method you put code that makes sure it’s a notification you want to respond to then extracts any needed information from the notification.  An example is below:

[Read More]

Today I Learned How To Create Xamarin iOS and Android Unit Tests

I’m currently working on a notification plugin for Xamarin Forms and wanted to setup some unit tests.  The problem is my code accesses the device-specific notification systems in iOS and Android.  This means I can’t just run my unit tests on Windows.  Instead I need to run the unit tests in a iOS or Android environment.  In my case this means an emulator.

How to do that?  Use the NUnit 3 Xamarin Runners.  It was not clear how to correctly create the test projects but the way that worked for me was this.

[Read More]

Notes on Converting Mini-Compressor to UWP Application (Trying to at Least)

I was inspired to get Mini-Compressor to UWP into the Windows 10 Store a while back this summer. I saw this video several months ago when it was called Project Centennial:

https://channel9.msdn.com/Events/Build/2015/2-692

Then a couple weeks ago there was a form you could fill out and a Microsoft employee would help you convert your application.  So I filled out the form about my tiny little application called Mini-Compressor and was surprised when I heard back.  The fellow was very helpful but in the end we couldn’t get Mini-Compressor ported to UWP.

[Read More]

Why I Created Migrator

OUM

Once upon a time in the far off land there a young handsome software developer.  This developer married the fairest maiden in the land and together they formed a company to slay problem monsters that prevented others from getting stuff done.  After a couple of successful adventures of banishing problem monsters the developer was asked by another problem monster slaying company to help deal with a monster bugging the local government.  The developer agreed to help.

[Read More]

Starting Any Method in a New Thread Using .NET

The main problem I encountered was creating a function to accept any function pointer along with an unknown number of arguments.  I got around this problem using the ThreadStart and delegate() features in C# (.NET 3.5).  First off create your method to take any method as so:

public static Thread StartMethodInNewThread(ThreadStart methodToStart)
{
    // Do common some stuff before starting the thread, such as logging.

    // Start the task in a new thread
    Thread t = new Thread(methodToStart);
    t.Start();

    // Do some stuff after starting the thread, such as more logging.

    // If the caller cares you can return the thread.
    return t;
}

Now anywhere in your code where you need to start a new method in a thread write the following:

[Read More]
Categories: code-examples  Tags: net threads