mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-04 00:00:14 -04:00
android: Expose static instance for Application object
While it seems to be possible to cast Context.getApplicationContext() to the application class, there really is no documented reason why that should actually be the same object.
This commit is contained in:
parent
36f62585bb
commit
8f04d15dfd
@ -49,6 +49,7 @@ public class StrongSwanApplication extends Application implements DefaultLifecyc
|
||||
private static final String TAG = StrongSwanApplication.class.getSimpleName();
|
||||
|
||||
private static Context mContext;
|
||||
private static StrongSwanApplication mInstance;
|
||||
|
||||
private final ExecutorService mExecutorService = Executors.newFixedThreadPool(4);
|
||||
private final Handler mMainHandler = HandlerCompat.createAsync(Looper.getMainLooper());
|
||||
@ -75,6 +76,7 @@ public class StrongSwanApplication extends Application implements DefaultLifecyc
|
||||
{
|
||||
super.onCreate();
|
||||
StrongSwanApplication.mContext = getApplicationContext();
|
||||
StrongSwanApplication.mInstance = this;
|
||||
|
||||
mManagedConfigurationService = new ManagedConfigurationService(mContext);
|
||||
ProcessLifecycleOwner.get().getLifecycle().addObserver(this);
|
||||
@ -120,6 +122,16 @@ public class StrongSwanApplication extends Application implements DefaultLifecyc
|
||||
return StrongSwanApplication.mContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current application object
|
||||
*
|
||||
* @return application
|
||||
*/
|
||||
public static StrongSwanApplication getInstance()
|
||||
{
|
||||
return StrongSwanApplication.mInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a thread pool to run tasks in separate threads
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user