我做了一个android项目库,在这个项目中只有一个类。该类用于从图库中获取所选图像的路径或从相机中获取保存的图像。
这是课程。
public class ImageBrowse extends Activity {
private static final int GALLERY_REQUEST = 1;
private static final int CAMERA_REQUEST = 1888;
private Uri selectedImageUri;
private static String imageRealPath = null;
private String imageName = null;
public String BrowseImageFromGallery(){
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(galleryIntent, GALLERY_REQUEST);
if(imageRealPath != null)
{
return imageRealPath;
}
return null;
}
public String TakeImageFromCamera(){
TakeImage();
return imageRealPath;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent ){
switch (resultCode){
case GALLERY_REQUEST : {
selectedImageUri = intent.getData();
imageRealPath = GetRealPathFromUri(selectedImageUri);
}
break;
case CAMERA_REQUEST : {
imageRealPath = GetRealPathFromUri(selectedImageUri);
}
break;
}
}
private String GetRealPathFromUri(Uri imageUri) {
try
{
String[] proj = {MediaStore.Images.Media.DATA};
@SuppressWarnings("deprecation")
Cursor cursor = managedQuery(imageUri, proj, null, null, null);
int column_Index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_Index);
}
catch(Exception e)
{
return imageUri.getPath();
}
}
private void TakeImage() {
ContentValues values = new ContentValues();
imageName = String.valueOf(System.currentTimeMillis());
values.put(MediaStore.Images.Media.TITLE, imageName);
selectedImageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
values);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, selectedImageUri);
startActivityForResult(intent, CAMERA_REQUEST);
}
}
我想从.net 中使用这个类,因此我使用了 IKVM.NET。但我收到警告无法编译类 ImageBrowse。下面是警告的图像。
如何删除此警告?