import android.preference.PreferenceFragment;
import android.support.v13.app.FragmentCompat;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
public class Preferences extends PreferenceFragment implements OnPreferenceClickListener, FragmentCompat.OnRequestPermissionsResultCallback {
if (ContextCompat.checkSelfPermission(activity, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity,
new String[]{ android.Manifest.permission.WRITE_EXTERNAL_STORAGE },
Constant.WRITE_STORAGE_PERMISSION);
}
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grants) { }
I'm trying to get the new permissions. The dialog shows up requesting the permission when it should, but onRequestPermissionResult it's never called, be it rejection or acceptance.
Any idea? The examples are all using Activity and not a Fragment, so that might be the problem. Also, I'm not sure which Compat I should be using (v4 vs v13). Min SDK is 14.
Aucun commentaire:
Enregistrer un commentaire