I have the following code in my Android app, and not sure whether it is my Googling skills, but am not able to find a good tutorial on how to monitor progress of InputStream.
private void restoreFromUri(Uri uri) {
try {
InputStream is = getContentResolver().openInputStream(uri);
ObjectInputStream ois = new ObjectInputStream(is);
ArrayList<String> myList = (ArrayList) ois.readObject();
ois.close();
is.close();
} catch (Exception e) {
Snackbar.make(snackView, e.getMessage(), Snackbar.LENGTH_LONG).show();
}
}
The above code works well, but in scenarios where the content is coming from GMail, even a small file takes a few seconds to read and populate the ArrayList.
Is it possible to show a progress bar with the percentage of file/content read?