I am creating an android app where I take a picture using camera intent, then store the picture in the picture directory. Then my app required to upload it. But, As I take the first picture from the app I can't see it in the gallery. But, from the second picture I take I can see them in the gallery. What to do?
here is my code: Here I display my pic on an image button:
mImageSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent galleryIntent=new Intent(Intent.ACTION_GET_CONTENT);
galleryIntent.setType("image/*");
startActivityForResult(galleryIntent,GALLERY_REQUEST);
}catch (Exception e){
Toast.makeText(getApplicationContext(),"There was an ERROR: "+e,Toast.LENGTH_LONG).show();
Intent intent=new Intent(PostActivity.this,AllPosts.class);
}
}
});
// I am saving it with mediastore.
MediaScannerConnection.scanFile(HomeActivity.this,
new String[] {imageFile.getAbsolutePath()},
new String[] {"image/jpeg"},null);
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(imageFile)));