Fix WorkManager initialization #438

Merged
Marown merged 1 commits from fix/workmanager into main 2024-08-16 07:17:56 +02:00
3 changed files with 8 additions and 6 deletions

View File

@ -184,6 +184,9 @@ public class SWADMain extends MenuExpandableListActivity {
initializeMainViews(); initializeMainViews();
try { try {
// Initialize WorkManager
workManager = WorkManager.getInstance(this);
// Create Notifications channel // Create Notifications channel
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
AlertNotificationFactory.createNotificationChanel(this); AlertNotificationFactory.createNotificationChanel(this);
@ -212,8 +215,6 @@ public class SWADMain extends MenuExpandableListActivity {
View view = findViewById(R.id.main_view); View view = findViewById(R.id.main_view);
setOnApplyWindowInsetsListener(view); setOnApplyWindowInsetsListener(view);
workManager = WorkManager.getInstance(this);
} catch (Exception ex) { } catch (Exception ex) {
error(ex.getMessage(), ex); error(ex.getMessage(), ex);
} }

View File

@ -271,6 +271,9 @@ public class Notifications extends Module implements
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
workManager = WorkManager.getInstance(this);
setContentView(R.layout.expandablelist_items_pulltorefresh); setContentView(R.layout.expandablelist_items_pulltorefresh);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -318,8 +321,6 @@ public class Notifications extends Module implements
View view = findViewById(R.id.expandablelist_items_pulltorefresh); View view = findViewById(R.id.expandablelist_items_pulltorefresh);
setOnApplyWindowInsetsListener(view); setOnApplyWindowInsetsListener(view);
workManager = WorkManager.getInstance(this);
} }
/** /**

View File

@ -149,6 +149,8 @@ public class PreferencesActivity extends PreferenceActivity implements OnPrefere
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
workManager = WorkManager.getInstance(ctx);
//Restore preferences //Restore preferences
getPreferenceManager().setSharedPreferencesName(Preferences.PREFS_NAME); getPreferenceManager().setSharedPreferencesName(Preferences.PREFS_NAME);
@ -238,8 +240,6 @@ public class PreferencesActivity extends PreferenceActivity implements OnPrefere
} catch (PackageManager.NameNotFoundException ex) { } catch (PackageManager.NameNotFoundException ex) {
error(ex.getMessage(), ex); error(ex.getMessage(), ex);
} }
workManager = WorkManager.getInstance(ctx);
} }
/* (non-Javadoc) /* (non-Javadoc)