0

I need to create a view to select a photo and store that photo in my local db.

I have tried:

private final int SELECT_IMAGE = 1;

In a button I put:

Intent i = new Intent(
Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

startActivityForResult(i, SELECT_IMAGE);

But when I select the picture, the intent close and dont return to my apk. Some here, my intent is finish. And the onActivityResult never runs. So, i can't handler...

My onActivityResult is this:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch(requestCode){
            case SELECT_IMAGE:
                if(resultCode==RESULT_OK){
                    Uri uri = data.getData();
                    String[] projection = {MediaStore.Images.Media.DATA};

                    Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
                    if(cursor.moveToFirst()){
                        int columnIndex = cursor.getColumnIndex(projection[0]);
                        String filePath = cursor.getString(columnIndex);
                    }
                    cursor.close();
                }
        }
    }

And to help, on LogCat I have NOTHING. Amazing...

I am using apk on API 7.

dwitvliet
  • 7,242
  • 7
  • 36
  • 62
  • I try this two links... http://stackoverflow.com/questions/17062150/trying-to-load-an-image-from-sdcard-on-android?rq=1 http://www.coderzheaven.com/2012/12/23/store-image-android-sqlite-retrieve-it/ but nothing... – Filipe Sampaio Jul 29 '14 at 14:51
  • I again... I solve my problem... In manifest i have the activity how handler that code with some extra options...like: android:noHistory="true" android:excludeFromRecents="true" Cant use that options in this activity... DONE!!! I houp this info help some one too... ;) Sory my write... – Filipe Sampaio Jul 30 '14 at 14:02

0 Answers0