I'm have a small problem.
objective of code: click an imageview that opens the camera, then after getting a picture change the imageview. the imageview is not a thumbnail of the photo.
the problem: the imageview does not refresh.
what I've tried: Android imageView Switching Problem, Changing ImageView on button click, ImageView onClickListener changing the image source (Can’t use viewSwitcher b/c have more than two possible view combinations), how to change the background or the image source when a clickable imageview in android is clicked?
My code:
public class CacTestActivity extends Activity {
private static final int CAMERA_PIC_REQUEST = 2500;
private Bitmap bmp;
private ImageView ivPic;
private Thread thread;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.cactest);
ivPic = (ImageView) findViewById(R.id.imgCacSetPhoto);
ivPic.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
try {
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA_PIC_REQUEST);
} catch (Exception e) {
}
}
});
thread = new Thread(){
@Override
public void run(){
ivPic = (ImageView) findViewById(R.id.imgCacSetPhoto);
ivPic.setImageResource(R.drawable.takephotoyes);
ivPic.invalidate();
}
};
}
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_PORTRAIT){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
if (resultCode == RESULT_OK){
if (requestCode == CAMERA_PIC_REQUEST){
//If getting pic bitmap is successful, then change imageview source
//thread.start(); //Does not work
}
}
}
}
This question has been asked many times before, but after much searching I've yet to find a solution. What am I missing? thanks