Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7090161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:00:43+00:00 2026-05-28T08:00:43+00:00

Well, in my application I’m using default camera and gallery of Android with startActivityforResult

  • 0

Well, in my application I’m using default camera and gallery of Android with startActivityforResult as;

Intent i = new Intent("android.intent.action.PICK",
                       MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
i.setType("image/*");
startActivityForResult(i, this.SELECT_PICTURE);

I am able to catch onActivityResult as well. However, if memory is low and I start this activity, I experienced that system is killing my parent activity, and even if the activity returns with a value, I lost all my local variables (and onCreate() is called again). Only onResume() should be called again.

I tried several times, I’m pretty sure that it is related with memory issue. If there is enough memory process is performed successfully. How can I prevent this behaviour?

Since Android doesn’t kill application in foreground, can I still use this feature? I think my problem is almost similar with this one .


Solution

In addition to solution provided by Yahel, usage of following methods can work.

@Override
public void onSaveInstanceState(Bundle savedInstanceState){
   super.onSaveInstanceState(savedInstanceState);
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState){
   super.onRestoreInstanceState(savedInstanceState);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:00:44+00:00Added an answer on May 28, 2026 at 8:00 am

    You need a good read of the must-read-before-you code article : http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

    You activitie can and will be killed by Android if memory is low. But it will be notified and there is a very well defined way of dealing with this.

    This is the reason of existence of the Bundle savedInstanceState in all your activities oncreate : public void onCreate(Bundle savedInstanceState)

    During the onpause of your app, you should save all you need to recreate the state your app is in and during the oncreate of your app you should check if you are coming back with a full savedInstanceState and restore your app from there.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to android application. My Android application works well on emulator but
Well.. we've developed a j2ee application using struts2 ajax capabilities. We find that the
Start a new web application using NetBeans 7 on GlassFish 3.1 In index.xhtml body
I'm using the mootools wall plugin, Its working well in my application, however if
I've got an issue trying to get the Android application (well, Service, it case
I am processing a word document using mergefield and bookmark.The application runs well while
I have written a simple facebook application using PHP SDK. Application works well but
I am building a secure web application. Currently, my application runs well using http
We have an application (well, 3) which uses Oracle 9i, however this is being
Our application is well structured (well we did our best!) and we have split

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.