これは、アクセス許可を処理する新しい方法の結果です。あなたのアプリケーションは、今は実行時の許可を求めて、却下の準備ができている必要があります。
あなたのonCreateで
(あるいはどこ)あなたがチェックし、おそらく許可を求める:
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.READ_EXTERNAL_STORAGE)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_MEDIA);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
次に、このような権限を受け入れる準備ができている:
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case MY_PERMISSIONS_REQUEST_READ_MEDIA: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
} else {
// permission denied, boo! Disable the
// functionality that depends on this permission.
}
return;
}
}
}
出典
2015-10-15 11:26:33
Ben
私は同じ問題に直面しています。 Youtubeに動画をアップロードしようとしていますが、同じエラーが発生しました。解決策を見つけましたか? – TOP
私はWhatsAppで写真を撮ると、チャットでLogCatで同じエラーが発生することに気付きました。だから、これは新しいランタイムのアクセス許可のため、Android 6の問題です。 –
フラグIntent.FLAG_GRANT_READ_URI_PERMISSIONを追加しようとしましたが、うまくいかないようです。 – TOP