简体   繁体   中英

Activity is recreated after resuming app from task manager list

I have an activity where we click image using,

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE, "NewPicture");
imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
takePictureIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(takePictureIntent, 2);

and have activity for result as,

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (resultCode == RESULT_OK)
    {
        mImageView.setImageBitmap(mImageBitmap);
    }
}

after clicking and saving photo onDestroy() is called so, I have used onSaveInstanceState(), onRestoreInstanceState() to resume same activity without recreating it when resumed from background(kept in background for 1 min or 10 secs) still the activity is not restored.

Issue occurs in low memory device currently using Samsung J1 with Version: 4.4.4, RAM:512 MB

How to solve this? Please help thanks in advance.

I have encounter this once, The problem with your device option 1.got to settings 2.find the developer options 3.In Apps section check the Don't keep activities is false..

what it means image picker is detached form activity as new activity. once user leaves the old activity it will kill by option on settings.

Check you may found..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM