我的代码
public class MainActivity extends Activity {
private View TakePhotoBtn;
private ImageView ProductPhoto;
private Button ReviewBtn;
public static File file;
private static final int CAMERA_REQUEST = 1888;
@Override
protected void onCreate(Bundle savedInstanceState) {
.....
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
void TakePhoto() {
Intent cameraIntent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
file = new File(Environment.getExternalStorageDirectory()
+ File.separator + "test.png");
Uri imageUri = Uri.fromFile(file);
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
imageUri);
BugTrackerApp.app.file =file ;
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
// this line is getting null value .... why
file = BugTrackerApp.app.file ;
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
ProductPhoto.setImageBitmap(bitmap);
ReviewAct.ImageFile = file;
}
}
}