android existing activity read intent of file from OnResume
- by manhon
I have associated my app with txt file.
So user can select a file in File explorer app and select my app to open it.
In OnCreate:
Intent intent = getIntent();
String action = intent.getAction();
if (action != null && action.equals(Intent.ACTION_VIEW)) {
txtFilePath = intent.getData().getPath();
}
However, when user did not close my app, and he goes back to file explorer and open another file, OnCreate is not called. OnResusme is called instead.
I put below code in OnResume:
Intent intent = getIntent();
String action = intent.getAction();
if (action != null && action.equals(Intent.MAIN)) {
txtFilePath = intent.getData().getPath();
}
However, txtFilePath is null. Why? Thank a lot for help.