Example usage for android.content Intent ACTION_PICK

List of usage examples for android.content Intent ACTION_PICK

Introduction

In this page you can find the example usage for android.content Intent ACTION_PICK.

Prototype

String ACTION_PICK

To view the source code for android.content Intent ACTION_PICK.

Click Source Link

Document

Activity Action: Pick an item from the data, returning what was selected.

Usage

From source file:com.ijiaban.yinxiang.MainActivity.java

/**
 * Opens the contact picker and allows the user to chose a contact.
 * onActivityResult will be called when returning to MainActivity.
 *///from www .j  a v a 2 s  .  c o  m
public void pickContact() {
    Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
    startActivityForResult(intent, PICK_CONTACT);
}

From source file:bmcx.aiton.com.passenger.view.activity.UploadUserDataActivity.java

/**
 * ?//from w  w w . j a v a  2 s .c  om
 */
public Intent getCropImageIntent() {
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    setIntentParams(intent);
    return intent;
}

From source file:com.grass.caishi.cc.activity.RegisterActivity.java

/**
 * ?/*from   w  w w .ja v a  2  s  . com*/
 */
public void selectPicFromLocal() {
    Intent intent;
    if (Build.VERSION.SDK_INT < 19) {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");

        // Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
        /*
         * intent.setType("image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 600); intent.putExtra("outputY", 600); intent.putExtra("scale", true); intent.putExtra("return-data", false); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUritest); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); // no face detection
         */
        // startActivityForResult(intent, CHOOSE_BIG_PICTURE);
    } else {
        intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        // startActivityForResult(intent, USERPIC_REQUEST_CODE_LOCAL_19);
    }
    startActivityForResult(intent, USERPIC_REQUEST_CODE_LOCAL);
}

From source file:rta.ae.sharekni.RegisterNewTest.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {//from   w w  w  .j a  va  2  s.co  m
        if (TakeATour.getInstance() != null) {
            TakeATour.getInstance().finish();
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    registerNewTestActivity = this;
    mContext = this;
    //        cal.add(Calendar.YEAR, -18);

    year_x = cal.get(Calendar.YEAR);
    month_x = cal.get(Calendar.MONTH);
    day_x = cal.get(Calendar.DAY_OF_MONTH);

    setContentView(R.layout.activity_register_new_test);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    //        txt_year = (TextView) findViewById(R.id.txt_year);
    //        txt_year.setText("0");
    txt_beforeCal = (TextView) findViewById(R.id.txt_beforeCal);
    txt_dayOfWeek = (TextView) findViewById(R.id.txt_dayOfWeek);
    showDialogOnButtonClick();

    driver_toggle = (ImageView) findViewById(R.id.driver_toggle);
    passenger_toogle = (ImageView) findViewById(R.id.passenger_toggle);
    both_toggle = (ImageView) findViewById(R.id.both_toggle);
    both_toggle_active = (ImageView) findViewById(R.id.both_toggle_active);
    driver_toggle_active = (ImageView) findViewById(R.id.driver_toggle_active);
    passenger_toggle_active = (ImageView) findViewById(R.id.passenger_toggle_active);

    btn_save = (Button) findViewById(R.id.btn_register_id);
    btn_upload_image = (Button) findViewById(R.id.btnUploadPhotoReg);
    edit_fname = (EditText) findViewById(R.id.edit_reg_fname);
    edit_lname = (EditText) findViewById(R.id.edit_reg_lname);
    edit_phone = (EditText) findViewById(R.id.edit_reg_phone);
    edit_pass = (EditText) findViewById(R.id.edit_reg_pass);
    edit_user = (EditText) findViewById(R.id.edit_reg_username);
    txt_comma = (TextView) findViewById(R.id.Register_comma_cal);
    malefemale_txt = (TextView) findViewById(R.id.malefemale_txt);
    femalemale_txt = (TextView) findViewById(R.id.femalemale_txt);

    malefemale = (ImageView) findViewById(R.id.malefemale);
    femalemale = (ImageView) findViewById(R.id.femalemale);

    //Terms_And_Cond_txt = (TextView) findViewById(R.id.Terms_And_Cond_txt);

    txt_lang = (TextView) findViewById(R.id.autocomplete_lang_id);
    txt_country = (AutoCompleteTextView) findViewById(R.id.autocompletecountry_id);

    Terms_And_Cond_txt_2 = (TextView) findViewById(R.id.Terms_And_Cond_txt_2);
    Terms_And_Cond_txt_2
            .setText(Html.fromHtml("<u><font color=#e72433>" + getString(R.string.reg_terms) + "</font></u>"));
    txt_terms = (RelativeLayout) findViewById(R.id.terms_relative);
    Privacy_and_poolicy = (TextView) findViewById(R.id.Privacy_and_poolicy);
    Privacy_and_poolicy
            .setText(Html.fromHtml("<u><font color=#e72433>" + getString(R.string.reg_policy) + "</font></u>"));

    FirstName_Linear = (LinearLayout) findViewById(R.id.FirstName_Linear);
    LastName_Linear = (LinearLayout) findViewById(R.id.LastName_Linear);
    MobileNumber_Linear = (LinearLayout) findViewById(R.id.MobileNumber_Linear);
    UserName_Linear = (LinearLayout) findViewById(R.id.UserName_Linear);
    Password_Linear = (LinearLayout) findViewById(R.id.Password_Linear);
    //   Nat_Linear = (LinearLayout) findViewById(R.id.Nat_Linear);
    Language_Linear = (LinearLayout) findViewById(R.id.Language_Linear);
    Date_Relative = (RelativeLayout) findViewById(R.id.datepicker_id);

    AgeCheckBox = (CheckBox) findViewById(R.id.AgeCheckBox);

    initToolbar();

    txt_terms.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getBaseContext(), TermsAndCond.class);
            startActivity(intent);

        }
    });

    Privacy_and_poolicy.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getBaseContext(), Privacy_Policy.class);
            startActivity(intent);
        }
    });

    btn_upload_image.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final CharSequence[] items = { getString(R.string.take_photo),
                    getString(R.string.choose_from_library), getString(R.string.cancel) };
            android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder(
                    RegisterNewTest.this);
            builder.setTitle(getString(R.string.add_photo));
            builder.setItems(items, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int item) {
                    if (items[item].equals(getString(R.string.take_photo))) {
                        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        startActivityForResult(intent, 0);
                    } else if (items[item].equals(getString(R.string.choose_from_library))) {
                        Intent intent = new Intent(Intent.ACTION_PICK,
                                MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                        intent.setType("image/*");
                        startActivityForResult(Intent.createChooser(intent, getString(R.string.select_file)),
                                1337);
                    } else if (items[item].equals(getString(R.string.cancel))) {
                        dialog.dismiss();
                    }
                }
            });
            builder.show();
        }
    });

    edit_fname.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                edit_fname.setHint(getString(R.string.Reg_FirstN));
                if (edit_fname.getText().length() == 0) {
                    FirstName_Linear.setBackgroundResource(R.drawable.user_register_border_error);
                } else {
                    FirstName_Linear.setBackgroundResource(R.drawable.user_register_border);
                }
            }
        }
    });

    edit_lname.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                edit_lname.setHint(getString(R.string.Reg_LastN));
                if (edit_lname.getText().length() == 0) {
                    LastName_Linear.setBackgroundResource(R.drawable.user_register_border_error);
                } else {
                    LastName_Linear.setBackgroundResource(R.drawable.user_register_border);
                }
            }
        }
    });

    edit_phone.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                edit_phone.setHint(getString(R.string.REg_Mobile));
                if (edit_phone != null) {
                    if (edit_phone.length() < 9) {
                        Toast.makeText(RegisterNewTest.this, getString(R.string.short_mobile),
                                Toast.LENGTH_SHORT).show();
                        MobileNumber_Linear.setBackgroundResource(R.drawable.user_register_border_error);
                    } else {
                        MobileNumber_Linear.setBackgroundResource(R.drawable.user_register_border);
                    }
                } else {
                    MobileNumber_Linear.setBackgroundResource(R.drawable.user_register_border);
                }
            }
            if (hasFocus) {
                edit_phone.setHint("");
            }
        }
    });

    edit_user.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                edit_user.setHint(getString(R.string.Reg_Email));
                if (!isEmailValid(edit_user.getText().toString())) {
                    vailedEmail = false;
                    UserName_Linear.setBackgroundResource(R.drawable.user_register_border_error);
                    Toast.makeText(RegisterNewTest.this, getString(R.string.email_valid_form),
                            Toast.LENGTH_SHORT).show();
                }
            } else {
                vailedEmail = true;
                UserName_Linear.setBackgroundResource(R.drawable.user_register_border);
            }
            if (hasFocus) {
                edit_user.setHint("");
            }
        }
    });

    edit_pass.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                edit_pass.setHint(R.string.password);
                if (edit_pass != null) {
                    if (edit_pass.length() <= 4) {
                        Password_Linear.setBackgroundResource(R.drawable.user_register_border_error);
                        Toast.makeText(RegisterNewTest.this, getString(R.string.short_pass), Toast.LENGTH_SHORT)
                                .show();
                    }
                }
            } else {
                Password_Linear.setBackgroundResource(R.drawable.user_register_border);
            }
            if (hasFocus) {
                edit_pass.setHint("");
            }
        }
    });

    //        txt_country.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    //            public void onFocusChange(View v, boolean hasFocus) {
    //                Boolean result = false;
    //                if (!hasFocus) {
    //                    txt_country.setHint(getString(R.string.nationality));
    //                    if (Country_List.size() != 0 && txt_country.getText() != null && !txt_country.getText().toString().equals(getString(R.string.nationality))) {
    //                        for (int i = 0; i <= 193; i++) {
    //                            String a = Country_List.get(i).get("NationalityEnName");
    //                            String b = txt_country.getText().toString();
    //                            if (a.equals(b)) {
    //                                result = true;
    //                            }
    //                        }
    //                    }
    //                    if (!result) {
    //                        txt_country.setBackgroundResource(R.drawable.user_register_border_error);
    //                        Toast.makeText(RegisterNewTest.this, R.string.unknown_country, Toast.LENGTH_SHORT).show();
    //                    } else {
    //                        txt_country.setBackgroundResource(R.drawable.user_register_border);
    //                    }
    //                }
    //                if (hasFocus) {
    //                    txt_country.setHint("");
    //                }
    //            }
    //        });

    txt_lang.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            Boolean result = false;
            if (!hasFocus) {
                txt_lang.setHint(getString(R.string.language));
                if (Lang_List.size() != 0 && txt_lang.getText() != null
                        && !txt_lang.getText().toString().equals(getString(R.string.Reg_PrefLang))) {
                    for (int i = 0; i <= Lang_List.size(); i++) {
                        String a = Lang_List.get(i).get("NationalityEnName");
                        String b = txt_lang.getText().toString();
                        if (a.equals(b)) {
                            result = true;
                        }
                    }
                } else {
                    Nat_Linear.setBackgroundResource(R.drawable.user_register_border);
                }
                if (!result) {
                    Nat_Linear.setBackgroundResource(R.drawable.user_register_border_error);
                    //                            Toast.makeText(RegisterNewTest.this, R.string.unknown_language, Toast.LENGTH_SHORT).show();
                }
            }
            if (hasFocus) {
                txt_lang.setHint("");
            }
        }
    });

    both_toggle.setOnClickListener(this);
    driver_toggle.setOnClickListener(this);
    passenger_toogle.setOnClickListener(this);
    both_toggle_active.setOnClickListener(this);
    passenger_toggle_active.setOnClickListener(this);
    driver_toggle_active.setOnClickListener(this);

    // get Languages
    new lang().execute();

    // get nationals
    //        new nat().execute();

    btn_save.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!vailedEmail) {
                UserName_Linear.setBackgroundResource(R.drawable.user_register_border_error);
            } else {
                UserName_Linear.setBackgroundResource(R.drawable.user_register_border);
            }

            if (edit_fname.getText().length() == 0) {
                FirstName_Linear.setBackgroundResource(R.drawable.user_register_border_error);
            } else {
                FirstName_Linear.setBackgroundResource(R.drawable.user_register_border);
            }
            if (edit_lname.getText().length() != 0) {
                LastName_Linear.setBackgroundResource(R.drawable.user_register_border);
            } else {
                LastName_Linear.setBackgroundResource(R.drawable.user_register_border_error);
            }
            if (edit_phone.getText().length() != 0) {
                MobileNumber_Linear.setBackgroundResource(R.drawable.user_register_border);
            } else {
                MobileNumber_Linear.setBackgroundResource(R.drawable.user_register_border_error);
            }
            if (edit_pass.getText().length() != 0) {
                Password_Linear.setBackgroundResource(R.drawable.user_register_border);
            } else {
                Password_Linear.setBackgroundResource(R.drawable.user_register_border_error);
            }

            //                if (txt_country.getText().length() != 0) {
            //                    Nat_Linear.setBackgroundResource(R.drawable.user_register_border);
            //                } else {
            //                    Nat_Linear.setBackgroundResource(R.drawable.user_register_border_error);
            //                }
            if (txt_lang.getText().length() != 0) {
                Language_Linear.setBackgroundResource(R.drawable.user_register_border);
            } else {
                Language_Linear.setBackgroundResource(R.drawable.user_register_border_error);
            }
            if (AgeCheckBox.isChecked()) {
                Date_Relative.setBackgroundResource(R.drawable.user_register_border);
            }
            if (!AgeCheckBox.isChecked()) {
                Toast.makeText(RegisterNewTest.this, R.string.fill_all_error, Toast.LENGTH_SHORT).show();
                Date_Relative.setBackgroundResource(R.drawable.user_register_border_error);
            } else {
                if (edit_fname.getText() != null
                        && !edit_fname.getText().toString().equals(getString(R.string.Reg_FirstN))
                        && edit_lname.getText() != null
                        && !edit_lname.getText().toString().equals(getString(R.string.Reg_LastN))
                        && edit_phone.getText() != null
                        && !edit_phone.getText().toString().equals(getString(R.string.REg_Mobile))
                        && edit_pass.getText() != null
                        && !edit_pass.getText().toString().equals(getString(R.string.Reg_pass))
                        && edit_user.getText() != null
                        && !edit_user.getText().toString().equals(getString(R.string.Reg_Email))
                        && !edit_lname.getText().toString().equals(getString(R.string.Reg_Nat))
                        && Language_ID != -1 && vailedEmail == true) {
                    ArrayList codes = new ArrayList();
                    codes.add("50");
                    codes.add("52");
                    codes.add("55");
                    codes.add("56");
                    String code = edit_phone.getText().toString().substring(0, 2);

                    if (edit_pass.getText().length() < 5) {
                        Toast.makeText(RegisterNewTest.this, R.string.Password_sould_be_more_than_five_chars,
                                Toast.LENGTH_SHORT).show();
                    } else {
                        if (!codes.contains(code)) {
                            Toast.makeText(RegisterNewTest.this, getString(R.string.short_mobile),
                                    Toast.LENGTH_SHORT).show();

                        } else {
                            String Fname = edit_fname.getText().toString();
                            String Lname = edit_lname.getText().toString();
                            String phone = edit_phone.getText().toString();
                            String pass = edit_pass.getText().toString();
                            String user = edit_user.getText().toString();
                            // String country = txt_country.getText().toString();
                            String country = "0";
                            //                        String lang = txt_lang.getText().toString();
                            char gender = i;
                            //    String birthdate = full_date;
                            int x = Language_ID;
                            //                            int y = Nationality_ID;
                            RegisterJsonParse registerJsonParse = new RegisterJsonParse();

                            switch (usertype) {
                            case "Passenger":
                                registerJsonParse.stringRequest(GetData.DOMAIN + "RegisterPassenger?firstName="
                                        + URLEncoder.encode(Fname) + "&lastName=" + URLEncoder.encode(Lname)
                                        + "&mobile=" + phone + "&username=" + URLEncoder.encode(user)
                                        + "&password=" + URLEncoder.encode(pass) + "&gender=" + gender
                                        + "&BirthDate=" + "&NationalityId=0" + "&PreferredLanguageId=" + x
                                        + "&photoName=" + uploadedImage, RegisterNewTest.this, country, "P");
                                Log.d("Registration :", GetData.DOMAIN + "RegisterPassenger?firstName="
                                        + URLEncoder.encode(Fname) + "&lastName=" + URLEncoder.encode(Lname)
                                        + "&mobile=" + phone + "&username=" + URLEncoder.encode(user)
                                        + "&password=" + URLEncoder.encode(pass) + "&gender=" + gender
                                        + "&BirthDate=" + "&NationalityId=0" + "&PreferredLanguageId=" + x
                                        + "&photoName=" + uploadedImage);
                                break;
                            case "1":
                                Toast.makeText(RegisterNewTest.this, R.string.select_type_first_error,
                                        Toast.LENGTH_SHORT).show();

                                break;
                            case "Driver":

                                registerJsonParse.stringRequest(
                                        GetData.DOMAIN + "RegisterDriver?firstName=" + URLEncoder.encode(Fname)
                                                + "&lastName=" + URLEncoder.encode(Lname) + "&mobile=" + phone
                                                + "&username=" + URLEncoder.encode(user) + "&password="
                                                + URLEncoder.encode(pass) + "&gender=" + gender + "&BirthDate="
                                                + "&licenseScannedFileName=nofile.jpg"
                                                + "&TrafficFileNo=nofile.jpg" + "&photoName=" + uploadedImage
                                                + "&NationalityId=0" + "&PreferredLanguageId=" + x,
                                        RegisterNewTest.this, country, "D");
                                Log.d("Reg Driver",
                                        GetData.DOMAIN + "RegisterDriver?firstName=" + URLEncoder.encode(Fname)
                                                + "&lastName=" + URLEncoder.encode(Lname) + "&mobile=" + phone
                                                + "&username=" + URLEncoder.encode(user) + "&password="
                                                + URLEncoder.encode(pass) + "&gender=" + gender + "&BirthDate="
                                                + "&licenseScannedFileName=nofile.jpg"
                                                + "&TrafficFileNo=nofile.jpg" + "&photoName=" + uploadedImage
                                                + "&NationalityId=0" + "&PreferredLanguageId=" + x);
                                break;
                            case "Both":
                                registerJsonParse.stringRequest(
                                        GetData.DOMAIN + "RegisterDriver?firstName=" + URLEncoder.encode(Fname)
                                                + "&lastName=" + URLEncoder.encode(Lname) + "&mobile=" + phone
                                                + "&username=" + URLEncoder.encode(user) + "&password="
                                                + URLEncoder.encode(pass) + "&gender=" + gender + "&BirthDate="
                                                + "&licenseScannedFileName=nofile.jpg"
                                                + "&TrafficFileNo=nofile.jpg" + "&photoName=" + uploadedImage
                                                + "&NationalityId=0" + "&PreferredLanguageId=" + x,
                                        RegisterNewTest.this, country, "D");
                                break;
                            }
                        }

                    }
                } else {
                    Toast.makeText(RegisterNewTest.this, R.string.fill_all_error, Toast.LENGTH_SHORT).show();
                }
            }

        }

        //            else {
        //                    Toast.makeText(RegisterNewTest.this, R.string.fill_all_error, Toast.LENGTH_SHORT).show();
        //                }
        //
    });

    malefemale.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            malefemale.setVisibility(View.INVISIBLE);
            femalemale.setVisibility(View.VISIBLE);
            malefemale_txt.setTextColor(Color.GRAY);
            femalemale_txt.setTextColor(Color.RED);
            i = 'F';

        }
    });

    femalemale.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            femalemale.setVisibility(View.INVISIBLE);
            malefemale.setVisibility(View.VISIBLE);
            malefemale_txt.setTextColor(Color.RED);
            femalemale_txt.setTextColor(Color.GRAY);
            i = 'M';
        }
    });

    femalemale_txt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            malefemale_txt.setTextColor(Color.GRAY);
            femalemale_txt.setTextColor(Color.RED);

            malefemale.setVisibility(View.INVISIBLE);
            femalemale.setVisibility(View.VISIBLE);
            i = 'M';

        }
    });

    malefemale_txt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            i = 'F';
            malefemale_txt.setTextColor(Color.RED);
            femalemale_txt.setTextColor(Color.GRAY);

            malefemale.setVisibility(View.VISIBLE);
            femalemale.setVisibility(View.INVISIBLE);
        }
    });

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}

From source file:com.money.manager.ex.common.CategoryListFragment.java

@Override
protected void setResult() {
    if (Intent.ACTION_PICK.equals(mAction)) {
        if (getExpandableListAdapter() == null)
            return;

        Intent result = null;/*from w w  w. java 2  s  .  co  m*/

        if (getExpandableListAdapter() instanceof CategoryExpandableListAdapter) {
            CategoryExpandableListAdapter adapter = (CategoryExpandableListAdapter) getExpandableListAdapter();
            int categId = adapter.getIdGroupChecked();
            int subCategId = adapter.getIdChildChecked();

            if (categId == ExpandableListView.INVALID_POSITION)
                return;

            for (int groupIndex = 0; groupIndex < mCategories.size(); groupIndex++) {
                if (mCategories.get(groupIndex).getId() == categId) {
                    // Get subcategory
                    if (subCategId != ExpandableListView.INVALID_POSITION) {
                        for (int child = 0; child < mSubCategories.get(mCategories.get(groupIndex))
                                .size(); child++) {
                            if (mSubCategories.get(mCategories.get(groupIndex)).get(child)
                                    .getSubCategId() == subCategId) {
                                result = new Intent();
                                result.putExtra(CategoryListActivity.INTENT_RESULT_CATEGID, categId);
                                result.putExtra(CategoryListActivity.INTENT_RESULT_CATEGNAME, mSubCategories
                                        .get(mCategories.get(groupIndex)).get(child).getCategName().toString());
                                result.putExtra(CategoryListActivity.INTENT_RESULT_SUBCATEGID, subCategId);
                                result.putExtra(CategoryListActivity.INTENT_RESULT_SUBCATEGNAME,
                                        mSubCategories.get(mCategories.get(groupIndex)).get(child)
                                                .getSubcategoryName().toString());
                                break;
                            }
                        }
                    } else {
                        result = new Intent();
                        result.putExtra(CategoryListActivity.INTENT_RESULT_CATEGID, categId);
                        result.putExtra(CategoryListActivity.INTENT_RESULT_CATEGNAME,
                                mCategories.get(groupIndex).getName());
                        result.putExtra(CategoryListActivity.INTENT_RESULT_SUBCATEGID, subCategId);
                        result.putExtra(CategoryListActivity.INTENT_RESULT_SUBCATEGNAME, "");
                    }
                }
            }
        }

        if (result != null) {
            result.putExtra(CategoryListActivity.KEY_REQUEST_ID, this.requestId);

            getActivity().setResult(Activity.RESULT_OK, result);
        } else {
            getActivity().setResult(Activity.RESULT_CANCELED);
        }
    }
}

From source file:org.egov.android.view.activity.CreateComplaintActivity.java

/**
 * Function called when choose the gallery option. Start the implicit intent ACTION_PICK for
 * result.//from  ww w .j  a v a  2 s  .c  om
 */
private void _openGalleryImages() {
    Intent photo_picker = new Intent(Intent.ACTION_PICK);
    photo_picker.setType("image/*");
    startActivityForResult(photo_picker, FROM_GALLERY);
}

From source file:com.mobility.android.ui.vehicle.AddVehicleActivity.java

private void pickFromGallery() {
    Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, GALLERY_REQUEST);
}

From source file:ca.ualberta.app.activity.CreateAnswerActivity.java

public void select_answer_pic(View view) {
    Intent intent = new Intent(Intent.ACTION_PICK, null);
    intent.setType("image/*");
    startActivityForResult(intent, GET_IMAGE_ACTIVITY_REQUEST_CODE);
}

From source file:com.ivanmagda.inventory.ui.ProductEditor.java

private void startPickImageIntent() {
    Intent galleryIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    startActivityForResult(galleryIntent, CHOOSE_PICTURE_RESULT);
}

From source file:com.rerum.beans.StorageActivity.java

@Override
public void onClick(View v) {
    int i = v.getId();
    if (i == R.id.button_camera) {
        Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
        photoPickerIntent.setType("image/*");
        startActivityForResult(photoPickerIntent, SELECT_PHOTO);
        //launchCamera();
    } else if (i == R.id.button_sign_in) {
        signInAnonymously();// w w  w . j a v  a 2 s . c o m
    } else if (i == R.id.button_download) {
        beginDownload();
    }
}