Update old lib (dagger) and new features of this app
I think this demo is old, please change dagger to hilt. I need some thing about contentprovider, service, broadcast receiver ... in android architecture recomment
Solution: Modernize and Extend the Android Architecture Sample
- Migrate from Dagger to Hilt Why? Hilt is the recommended DI framework by Google and simplifies setup significantly.
Steps:
Add Hilt dependencies to build.gradle (app & project level).
Replace Dagger components/modules with @HiltAndroidApp, @AndroidEntryPoint, @Inject, @HiltViewModel.
Remove old @Component and @Module wiring.
// In Application class @HiltAndroidApp class TodoApplication : Application()
// In Activities/Fragments/ViewModels @AndroidEntryPoint class TasksActivity : AppCompatActivity()
@HiltViewModel class TasksViewModel @Inject constructor(...) : ViewModel() Dependency:
implementation "com.google.dagger:hilt-android:2.51.1" kapt "com.google.dagger:hilt-compiler:2.51.1" 2. Add Architecture-Recommended Components a. Content Provider Example Create a TaskProvider to expose tasks via a content URI.
Expose querying/filtering of task list from other apps.
override fun query(...): Cursor? { return database.query("tasks", ...) } b. BroadcastReceiver Use Use BroadcastReceiver for background state notifications or reminders.
Example:
class TaskAlarmReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { // Show notification } } c. Service Component Example Add a simple ForegroundService that syncs tasks with server.
class SyncService : Service() { override fun onStartCommand(...) { // Start task sync in coroutine or background thread return START_STICKY } } 3. Enhance with Modern Android Features Jetpack Compose support: Optionally add a Compose-based screen.
Flow instead of LiveData: Many parts already use Flow, continue this pattern for consistency.
WorkManager: For background syncs instead of manual Service.
- Code Cleanups and Testing Use SavedStateHandle in ViewModel for config-safe state management.
Add @OptIn(ExperimentalCoroutinesApi::class) for test APIs.
Migrate tests to use Hilt testing support.