Reputation: 187
class AlmatyJobViewModel(application: Application) : AndroidViewModel(application){
fun clearSuggestionsHistory(){
SearchRecentSuggestions(application, MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE)
.clearHistory()
}
}
Unresolved Referense: application
How to get application from constructor, if i want to use it in this method?
Upvotes: 2
Views: 103
Reputation: 661
If you add private val application
you will have exceptions in compilation time like
Accidental override: The following declarations have the same JVM signature
So, to fix it, you only should to call getApplication()
where you require.
SearchRecentSuggestions(getApplication(), MySuggestionsProvider.AUTHORITY, MySuggestionsProvider.MODE).clearHistory()
Upvotes: 3