What's the best way to check for permissions at runtime using MVP architecture? : <p>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.</p>

<p>My initial thought was to have the presenter call a component responsible for permissions(say a <code>PermissionHandler</code>), and update view accordingly.</p>

<p>The issue is that the code to check for permissions is tightly coupled with the Activity class. Here are some of the methods involved that require an Activity or Context:</p>

<ul>
<li><code>ContextCompat.checkSelfPermission()</code></li>
<li><code>ActivityCompat.shouldShowRequestPermissionRationale()</code></li>
<li><code>ActivityCompat.requestPermissions()</code></li>
<li><code>onRequestPermissionsResult()</code>(callback)</li>
</ul>

<p>This means I would have to pass an activity object to the presenter, which I didn't like much because I've heard that keeping your presenter free from Android code is good for testing.</p>

<p>Due to that, I then thought about handling permissions at view level(in an activity), but then I guess this would hurt the purpose of leaving the view responsible only for UI updates, without business logic.</p>

<p>I'm not sure what would be the best approach to tackle that keeping the code as decoupled and maintainable as possible. Any ideas?</p>
