StartActivityForResult does not returns anything (Image Picking from a PreferenceActivity)?

Must work, added whole class: import android.app. Activity; import android.content. Intent; import android.os.

Bundle; public class StackOverflowAppActivity extends Activity { private final int PICK_IMAGE = 0; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout.

Main); Intent I = new Intent(Intent. ACTION_PICK, android.provider.MediaStore.Images.Media. EXTERNAL_CONTENT_URI); startActivityForResult(i, PICK_IMAGE); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.

OnActivityResult(requestCode, resultCode, data); switch (requestCode) { case PICK_IMAGE: if (resultCode == RESULT_OK) { // do your thing } } } }.

Creating a new project with a new Activity, works. But on my PreferenceActivity, not. That's why I think I have to add something to the whole PreferenceActivity class or to the manifest.

– xuso Jun 26 at 13:48 show your whole class then, otherwise we cannot help – evilone Jun 26 at 13:50 Added to the first post, almost my whole Settings class and my manifest. Keep thinking lacks something in manifest's – xuso Jun 26 at 14:05 try adding super. OnActivityResult(requestCode, resultCode, data); to your onActivityResult method, like in my example – evilone Jun 26 at 14:14 I don't know why but now works :O .

I swear, I had tried that before and did not work... but now, it works... thanks a lot @evilone ;) – xuso Jun 26 at 14:26.

Use the below code .. probably this can solve your problem. Protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super. OnActivityResult(requestCode, resultCode, imageReturnedIntent); switch(requestCode) { case REQ_CODE_PICK_IMAGE: if(resultCode == RESULT_OK){ Uri selectedImage = imageReturnedIntent.getData(); String filePathColumn = {MediaStore.Images.Media.

DATA}; Cursor cursor = getContentResolver(). Query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor. GetColumnIndex(filePathColumn0); String filePath = cursor.

GetString(columnIndex); cursor.close(); Bitmap yourSelectedImage = BitmapFactory. DecodeFile(filePath); } } }.

Gr8 it works ... good to know – success_anil Jun 26 at 13:43 1 False alarm. Does not work. :( BTW, the problem is not the code inside onActivityResult... this method is never called.

– xuso Jun 26 at 13:43.

That is, startActivityForResult() returns quickly and you do not have the result yet. In order to receive the result (once it is available), you must provide an onActivityResult(int, int, Intent) method in your calling class. That method will be called automatically once the result is available.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions