Code example for FragmentActivity

Methods: onCreate, startActivityForResult

0
 
    // onCreate, startActivityForResult, getImageToWhiteboard 
 
    @Override 
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
 
        Intent gallery = new Intent(Intent.ACTION_GET_CONTENT);
        gallery.setType("image/*");
        startActivityForResult(Intent.createChooser(gallery, null), REQUEST_CONTENT);
    } 
 
    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CONTENT) {
            if (resultCode != RESULT_OK) {
                finish(); 
                return; 
            } 
 
            // Query gallery for camera picture via