I have an Activity
(A) which is downloading a file and putting the data(some book titles) from it into a listView
. And from this Activity
(A) i starter another Activity
(B) which i can do some work with it. The problem is when i wanna back to (A)
calling this.finish()
using a button(from B
), the file starts downloading again(although it has been downloaded).
I am using a DownloadManager
to download the file and a String[] book
to put the contents of the downloading file.
I tried to save my Activity State
, like this(i don't want the file to be downloaded again):
protected void onSaveInstanceState(Bundle state) {
DownloadManager downloadManager = null;
super.onSaveInstanceState(state);
state.putStringArray("message", book);
state.putParcelable("message1", (Parcelable) downloadManager);
}
And to recreate my Activity
, i tried this(i don't want the file to be downloaded again):
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
if (wifiManager.setWifiEnabled(true)) {
book= savedInstanceState.getStringArray("message");
downloadReference = savedInstanceState.getParcelable("message1");
}
}
But the app crash when i wanna back from B
to A
. Any help or hints to show me how i can go from B
to A
without downloading the file each time is very welcome. Thanks in advance, Carl.