From 987852294cd5fb397670493cf59831fa0d21dfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81bastiaan?= Date: Sat, 2 Apr 2016 16:04:30 +0200 Subject: [PATCH] Add permission request to sample application --- .../torrentstreamer/sample/MainActivity.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sample/src/main/java/com/github/se_bastiaan/torrentstreamer/sample/MainActivity.java b/sample/src/main/java/com/github/se_bastiaan/torrentstreamer/sample/MainActivity.java index d7cc5ca..03a50b2 100644 --- a/sample/src/main/java/com/github/se_bastiaan/torrentstreamer/sample/MainActivity.java +++ b/sample/src/main/java/com/github/se_bastiaan/torrentstreamer/sample/MainActivity.java @@ -19,11 +19,15 @@ package com.github.se_bastiaan.torrentstreamer.sample; +import android.Manifest; import android.annotation.SuppressLint; import android.content.Intent; +import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; import android.os.Environment; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; @@ -78,6 +82,15 @@ protected void onCreate(Bundle savedInstanceState) { progressBar.setMax(100); } + @Override + protected void onResume() { + super.onResume(); + + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0); + } + } + View.OnClickListener mOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) {