1

I have a game screen and in the middle of the game, the player can change theri profile pic by clicking a button. when the button is clicked, the following method is called

private static final int SELECT_PHOTOA = 100;    
public void chgImageA(View v){

    System.out.println("...changing profile a");
    Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, SELECT_PHOTOA);

}

Then in the onActivityResult method I have the following code

@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
 if (requestCode == SELECT_PHOTOA) {

        if(responseCode == RESULT_OK){
            Uri uri = intent.getData();
            ImageButton pap= (ImageButton)findViewById(R.id.profileAButton);
            pap.setImageURI(uri);
        }

    }
}

This calls the photo picker and changes the profile pic on the Imagebutton, but the parent activity that called this imagepicker activity is restarted. How do I get the first activity to resume from where it was? Any help would be greatly appreciated...thnakyou!!!

Aparna
  • 835
  • 2
  • 23
  • 47
  • i think it may cause of orientation change just add android:configChanges="orientation|keyboard|screenSize" to activity in manifest and check – Pavan Sep 03 '15 at 15:48
  • Thankyou for your answer, but I already have the following in my manifest – Aparna Sep 03 '15 at 15:54
  • second cause may be memory concern in this case may android system may close your activity check with this http://stackoverflow.com/questions/14622279/camera-or-gallery-intent-destroys-old-activity-on-some-devices – Pavan Sep 03 '15 at 15:57
  • Thankyou very much!!...I do have low memory on my device. Also when I run the debugger, I find that when the button is pressed, startActivityForResult is started and then it goes to the onCreate() method and then to the onActivityResult(). Is that the normal flow. I will check the memory issue too...Thankyou very much for your help!!! – Aparna Sep 03 '15 at 16:11
  • 1
    welcoe,nice it helped you after startActivityForResult your system destroying your activity which is not normal flow its memory issue so you have to handle onSaveInstanceState and onRestoreInstanceState – Pavan Sep 03 '15 at 16:16
  • Thanks again...Also do you know of a way/command to force the dalvik to keep the parent activity in stack and not eject it out? – Aparna Sep 03 '15 at 16:20
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/88722/discussion-between-pavan-and-aparna). – Pavan Sep 03 '15 at 16:22

0 Answers0