エミュレータの画像フォルダから画像を取り込んで、アプリケーションのレイアウトに選択した画像を表示するアプリを作成しました。
私は、インスタントアプリに私のアプリを変換すると、画像フォルダから画像をピックアップする同じコードが例外をスローします。私は、READ_EXTERNAL_STORAGEの実行時アクセス許可を使用しました。以下である
**AndroidインスタントアプリからGalleryを起動できません
java.lang.SecurityException: Not allowed to start activity Intent {
act=android.intent.action.GET_CONTENT typ=*/* }
**
:以下の例外がスローされ
private static final int PICK_IMAGE_REQUEST = 234;
Intent intent = new Intent();
intent.setType("*/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, PICK_IMAGE_REQUEST);
:
以下は私のコードですrのコード除外権限:
private static final int REQUEST_WRITE_STORAGE = 112;
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public boolean checkPermission()
{
int currentAPIVersion = Build.VERSION.SDK_INT;
if(currentAPIVersion>=android.os.Build.VERSION_CODES.M)
{
if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)) {
Toast.makeText(MainActivity.this,"Permission Denied...",Toast.LENGTH_LONG).show();
} else {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, REQUEST_WRITE_STORAGE);
return true;
}
return false;
} else {
return true;
}
} else {
return true;
}
}
誰でもこの問題を解決するのに役立ちますか?
ありがとうございました。
どうやってそれに対処しましたか? – Kenji