Android Image Viewer Getting Results Back

The android image viewer getting results back tutorial is the third part to the android image viewer tutorial series.

Where the viewers will be shown how to create a basic android application that  loads an image thumbnail and then displays it on the full screen.

This android tutorial series targeted towards beginners to android who would like to learn how to create a basic android application.

In this tutorial we show how to get the data back from the intent request we made in the previous tutorial.

Get Code

The code for this tutorial can be found on github here

https://github.com/mobapptuts/android_image_viewer.git Tag image-viewer-onactivityresult

or you can run this command

git clone https://github.com/mobapptuts/android_image_viewer.git –branch image-viewer-onactivityresult

Code Samples

Accessing the onActivityResult method

When we call the startActivityForResult method, once our request has been called the onActivityResult will be called supplying details of our requestId, whether our request was successful and if so the data containing our image.

@Override
    public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
        if(requestCode == REQUEST_FOLDER_CODE && resultCode == RESULT_OK) {
            Uri uri = null;
            if(resultData != null) {
                uri = resultData.getData();
             }
        }
    }

Android Image Viewer Getting Results Back Summary

In this tutorial we learned

  • How to access the results of an intent request
  • Checking the requestId
  • Checking whether the request was successful
  • How to get the data from the intent returned.
About The Author
-

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>