From 6684195505c8d034cffab60e621921cc77f4bdde Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 30 May 2014 12:35:54 +0200 Subject: [PATCH] android: Subclass Application to provide static access to the application context --- src/frontends/android/AndroidManifest.xml | 1 + .../android/logic/StrongSwanApplication.java | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/frontends/android/src/org/strongswan/android/logic/StrongSwanApplication.java diff --git a/src/frontends/android/AndroidManifest.xml b/src/frontends/android/AndroidManifest.xml index 721d0c0fe..e2d25e4ac 100644 --- a/src/frontends/android/AndroidManifest.xml +++ b/src/frontends/android/AndroidManifest.xml @@ -26,6 +26,7 @@ . + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +package org.strongswan.android.logic; + +import android.app.Application; +import android.content.Context; + +public class StrongSwanApplication extends Application +{ + private static Context mContext; + + @Override + public void onCreate() + { + super.onCreate(); + StrongSwanApplication.mContext = getApplicationContext(); + } + + /** + * Returns the current application context + * @return context + */ + public static Context getContext() + { + return StrongSwanApplication.mContext; + } +}