1
1
package rocks .tbog .tblauncher .handler ;
2
2
3
+ import android .app .Application ;
3
4
import android .app .KeyguardManager ;
4
5
import android .content .BroadcastReceiver ;
5
6
import android .content .ComponentName ;
@@ -104,7 +105,7 @@ public class DataHandler extends BroadcastReceiver
104
105
);
105
106
106
107
@ NonNull
107
- private final Context context ;
108
+ private final Application mApplication ;
108
109
private String currentQuery ;
109
110
private final Map <String , ProviderEntry > providers = new LinkedHashMap <>(); // preserve insert order
110
111
private boolean mFullLoadOverSent = false ;
@@ -114,11 +115,12 @@ public class DataHandler extends BroadcastReceiver
114
115
/**
115
116
* Initialize all providers
116
117
*/
117
- public DataHandler (Context ctx ) {
118
+ public DataHandler (@ NonNull Application app ) {
118
119
// Make sure we are in the context of the main application
119
120
// (otherwise we might receive an exception about broadcast listeners not being able
120
121
// to bind to services)
121
- context = ctx .getApplicationContext ();
122
+ mApplication = app ;
123
+ Context ctx = app .getApplicationContext ();
122
124
123
125
mTimer .start ();
124
126
@@ -130,7 +132,7 @@ public DataHandler(Context ctx) {
130
132
ctx .sendBroadcast (i );
131
133
132
134
// Monitor changes for service preferences (to automatically start and stop services)
133
- SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences (context );
135
+ SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences (ctx );
134
136
prefs .registerOnSharedPreferenceChangeListener (this );
135
137
136
138
// add DB providers
@@ -161,7 +163,7 @@ public DataHandler(Context ctx) {
161
163
162
164
@ NonNull
163
165
public Context getContext () {
164
- return context ;
166
+ return mApplication . getApplicationContext () ;
165
167
}
166
168
167
169
/*
@@ -170,6 +172,7 @@ public Context getContext() {
170
172
* to them dynamically.
171
173
*/
172
174
private void basicProviders () {
175
+ Context context = mApplication ;
173
176
// Filters
174
177
{
175
178
ProviderEntry providerEntry = new ProviderEntry ();
0 commit comments