Skip to content

Instantly share code, notes, and snippets.

@trinnguyen
Created February 27, 2016 08:33
Show Gist options
  • Save trinnguyen/65d6a2bf905c5e085acf to your computer and use it in GitHub Desktop.
Save trinnguyen/65d6a2bf905c5e085acf to your computer and use it in GitHub Desktop.
Xamarin.Android override Application class to get global Context
using System;
using Android.App;
namespace MyApp.Droid
{
[Application(Theme = "@style/MyMaterialTheme")]
public class MyApplication : Application
{
public static Android.Content.Context CurrentContext { get; private set; }
public MyApplication()
{
}
public override void OnCreate()
{
base.OnCreate();
MyApplication.CurrentContext = ApplicationContext;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment