In my mainactivity
class, on clicking a button, it displays a dialog that shows, "capture a photo", "capture a video", pick from gallery" buttons upon clicking any of those button it has to do the respective action and return the path of file to mainactivity
.
It is easy to do with startActivityForResult&onActivityResult
within mainactivity
.
But how can I use intent with in custom dialog and return the intent result from custom dialog to mainactivity
.
Thanks for your time.
takeaPhoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, ACTION_TAKE_PHOTO);
}
});
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(){
//do action
String filePath = data.getDataString();
filename.setText(filePath);
}
}