I have a doubt regarding the choice between @Singleton or @ActivityScoped.
What should I choose if both can work smoothly with Hilt?
@Singleton scoped class:
Retained in memory for the lifetime of the application.
Potential fear of memory leaks.
@ActivityScoped:
Scoped to the lifecycle of an activity.
Helps manage resources and memory more efficiently within the scope of an activity.
Here is an example of a @Singleton scoped class:
@Singleton
public class CertificateFileUseCase {
Context context;
private File destPath;
@Inject
public CertificateFileUseCase(Context context) {
this.context = context;
}
}
Any advice on which to choose and why?
Thank you!