Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solved problem in android version <= 6 , not call permissions and not… #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ public void onChange(boolean selfChange, Uri uri) {
};
getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, observer);

checkPermission();
// EudesSilva: BugFix: #24
if( !checkPermission() ){ // call direct functions in android versions <= 6
loadAlbums();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
Expand All @@ -24,16 +25,27 @@ public class HelperActivity extends AppCompatActivity {
private final int maxLines = 4;
private final String[] permissions = new String[]{ Manifest.permission.WRITE_EXTERNAL_STORAGE };

protected void checkPermission() {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
permissionGranted();

} else {
ActivityCompat.requestPermissions(this, permissions, Constants.PERMISSION_REQUEST_CODE);
protected boolean checkPermission() {
if (!isMarshmallow()) {
return false;
}else {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
permissionGranted();

} else {
ActivityCompat.requestPermissions(this, permissions, Constants.PERMISSION_REQUEST_CODE);
}
return true;
}
}

// EudesSilva: BugFix: #24
// verify if version android is 6 or hight
private boolean isMarshmallow(){
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
}

private void requestPermission() {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
showRequestPermissionRationale();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ public void onChange(boolean selfChange) {
};
getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, observer);

checkPermission();
// EudesSilva: BugFix: #24
if( !checkPermission() ){ // call direct functions in android versions <= 6
loadImages();
}
}

@Override
Expand Down