If you use whatsapp and you click the attach button, a menu/popup will be inflated showing you a list of appications you can use to select images and even take pictures from your camera using the photo app
I making an app that have almost the same functionality as whatapp of accessing and taking pictures. the problem is, I can't take pictures using the photo app listed as one of apps in my popup dialog but i can take pictures when using whatsapp. When I click photo app from the dialog shown in my application, it shows me all my pictures. but when I click the photo app from whatsapp popup, it goes directly to the camera
public class ImagePickerActivity extends Activity {
private final int SELECT_PHOTO = 1;
private ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_image_picker);
imageView = (ImageView)findViewById(R.id.imageView);
Button pickImage = (Button) findViewById(R.id.btn_pick);
pickImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode) {
case SELECT_PHOTO:
if(resultCode == RESULT_OK){
try {
final Uri imageUri = imageReturnedIntent.getData();
final InputStream imageStream = getContentResolver().openInputStream(imageUri);
final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream);
imageView.setImageBitmap(selectedImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
}
In my android manifest
<uses-feature android:name="android.hardware.camera"
android:required="true" />
What do I need to change in my code to be able to take pictures from photo app?