0
我想上傳圖片在我的應用程序,我想顯示一些選擇,當我的上傳按鈕被點擊。不幸的是,它給了我這個錯誤。我不知道代碼有什麼問題。我提前得到這個從這裏Trying open a specific folder in android using intent單擊按鈕時如何顯示文件選擇器?
的感謝!
uploadpic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
openFolder();
}
});
}
public void openFolder()
{
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()
+ "/Pictures/");
intent.setDataAndType(uri, "images");
startActivity(Intent.createChooser(intent, "Open folder"));
takephoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
dispatchTakePictureIntent();
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
profpic.setImageBitmap(imageBitmap);
}
}
static final int REQUEST_IMAGE_CAPTURE = 1;
private void dispatchTakePictureIntent() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
}