Created
February 27, 2016 08:33
-
-
Save trinnguyen/65d6a2bf905c5e085acf to your computer and use it in GitHub Desktop.
Xamarin.Android override Application class to get global Context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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