为什么即使imageUri不为null或为空,Parcel文件描述符也会抛出FileNotFounException。我使用Intent从我的库中选择了一个文件。我还提供“imageUri”的值,它会打印出来。
ParcelFileDescriptor percelFileDescriptor;
Toast.makeText(getApplicationContext(),""+imageUri.toString(),Toast.LENGTH_LONG).show();
try {
percelFileDescriptor = getContentResolver().openFileDescriptor(imageUri, "r");
image = BitmapFactory.decodeFileDescriptor(percelFileDescriptor.getFileDescriptor());
modified_img_bitmap = image;
percelFileDescriptor.close();
picked_image.setImageBitmap(image);
} catch (FileNotFoundException e) {
System.out.println("File Not Found: " + e.toString());
Toast.makeText(getApplicationContext(),"File not found: "+e.toString(),Toast.LENGTH_LONG).show();
} catch (IOException e) {
Toast.makeText(getApplicationContext(),"IO Error: "+e.toString(),Toast.LENGTH_LONG).show();
System.out.println("IO Exception: " + e.toString());
}
}
答案 0 :(得分:0)
我尝试了你的代码并且有效。请发布完整的代码。
有效:
var map = new google.maps.Map(mappnl.el.dom, {
zoom: 8,
center: {
lat: 52.132633,
lng: 5.291265999999999
},
mapTypeId: google.maps.MapTypeId.TERRAIN
});
var latlong = [];
var geocoder = new google.maps.Geocoder();
if(frmvalue.dir_postalcode_standard){
geocoder.geocode({
'address': frmvalue.dir_postalcode_standard
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
slat = results[0].geometry.location.lat();
slng = results[0].geometry.location.lng();
latlong['standard'] = {
'lat': slat,
'lng': slng
};
var cityCircle = new google.maps.Circle({
strokeColor: '#00FF00',
strokeOpacity: 0.8,
strokeWeight: 1,
fillColor: '#00FF00',
fillOpacity: 0.15,
map: map,
center: {
lat: slat,
lng: slng
},
radius: frmvalue.dir_radius_standaard * 1000
});
map.setCenter({
lat: slat,
lng: slng
});
geocoder.geocode({
'address': frmvalue.dir_postalcode_extended
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
elat = results[0].geometry.location.lat();
elng = results[0].geometry.location.lng();
latlong['extended'] = {
'lat': elat,
'lng': elng
};
var cityCircle = new google.maps.Circle({
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 1,
fillColor: '#FF0000',
fillOpacity: 0.15,
map: map,
center: {
lat: elat,
lng: elng
},
radius: frmvalue.dir_radius_extended * 1000
});
callback(latlong);
} else {
console.log("Geocode was not successful for the following reason: " + status);
}
});
} else {
console.log("Geocode was not successful for the following reason: " + status);
}
});
} else {
callback(false);
}