I\'m developing an android app in which I have to ask for permissions at runtime. I\'m wondering about the best way to implement that using Model-View-Presenter architecture.
What I would do is:
The view will implement:
public Activity getViewActivity();
The presenter will implement:
public void requestPermissions();
public void onPermissionsResult();
Inside requestPermissions
, the presenter will do: getViewActivity().checkSelfPermission; getViewActivity.requestPermissions(); etc.
The view will call inside the onRequestPermissionsResult
callback to presenter.onPermissionsResult();
With this all the logic will be implemented inside the presenter.
In my opinion, your presenter is decoupled: it won't depend on any view implementation (it will only depend on the view interface).
"I've heard that keeping your presenter free from Android code is good for testing." I don't understand this part. If the code is good, it can be tested without any problem.