Requesting Runtime Permission from Custom Dialog in Android
<p>I am developing an application which shows a custom listview of notes and a Button for adding a new note. When user clicks on button, app shows a full screen dialog to add note with some additional detail. User can also upload an attachment with note as clicking on attachment button. but the problem is after <strong>Android M(API 23)</strong> this task requires runtime permission.</p>

<p>According to <a href="https://developer.android.com/training/permissions/requesting.html" rel="nofollow noreferrer">Google Developers</a>, result of permission request will be delivered in <code>onRequestPermissionsResult()</code> method. I don't know how can I get this result in method which I used to show fullscreen dialog.</p>

<p>This is how my method looks like:</p>

<pre><code>private void showCreateNoteDialog() {

    //create dialog body...
    final Dialog createDialog = new Dialog(NotesActivity.this,R.style.MyFullscreenDialog);
    createDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    LayoutInflater inflater = this.getLayoutInflater();
    createDialog.setContentView(inflater.inflate(R.layout.customdialog_createNote, null));
    createDialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);}
</code></pre>

<p><strong>Edit :</strong></p>

<p>The permission require for uploading a file is <strong>Read from Sd card or External storage</strong></p>