0

In my app, I try to load a file with the following code :

    intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.setType("application/octet-stream");
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    startActivityForResult(intent, CODE_FOR_LOADING);

It works : the file picker is correctly displayed and I can choose the file I want to read and I successfully read it.

My problem is that when or just before the file picker is displayed, I can notice my onSaveInstanceStatefunction is called and it doesn't seem logical to me...

Anybody knows why it happens and if a mean to avoid this exists?

Zelig63
  • 1,592
  • 1
  • 23
  • 40
  • It happens when OS kills your Activity in order to preserve memory .. [See this thread](https://stackoverflow.com/questions/16014930/android-activity-getting-destroyed-after-calling-camera-intent) or similar .. – ADM Apr 22 '20 at 08:32
  • But why would the system kill my Activity? It is running in the foreground, and I don't think the file picker uses so many memory that my device can't handle both. – Zelig63 Apr 22 '20 at 09:07

0 Answers0