In my view I have button which start recording audio I want to ask user to grant permission when user click on the button.
For example: How to ask permission for fine localization in BasicExample?
I think it's the work of the UI which means you don't do that in the ViewModel. I dont like the Databinding stuff in ViewModel either. Just create a Clicklistener or use databinding to set a listener to your layout.
After this is done just request your permissions in your view/activity/fragment. Why? Because ViewModel is/should be Businesslogic. Always think about testing (without Android device). Everything you are able to test > viewmodel. Everything UI relevanted stuff -> View.
I may be wrong if you dont use mvvm but mvp or mvc.
Agree with @mynote , that's the work of View layer, not ViewModel layer.
@mynote +1. OS interactions needs to stay in the activity / fragment.
how about true mvvm (which many of us trying to build on top of databindings lib)? the ui event handlers are part of view model there.
Most helpful comment
I think it's the work of the UI which means you don't do that in the ViewModel. I dont like the Databinding stuff in ViewModel either. Just create a Clicklistener or use databinding to set a listener to your layout.
After this is done just request your permissions in your view/activity/fragment. Why? Because ViewModel is/should be Businesslogic. Always think about testing (without Android device). Everything you are able to test > viewmodel. Everything UI relevanted stuff -> View.
I may be wrong if you dont use mvvm but mvp or mvc.